summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/logerr.c3
-rw-r--r--src/logerr.h6
-rw-r--r--tests/logerr.c27
3 files changed, 16 insertions, 20 deletions
diff --git a/src/logerr.c b/src/logerr.c
index 284f8ad..fac87f0 100644
--- a/src/logerr.c
+++ b/src/logerr.c
@@ -7,6 +7,7 @@
#include "logerr.h"
+
void
vlogerr(
const char *const file,
@@ -30,6 +31,4 @@ vlogerr(
if (fprintf(stream, "\n") < 0) {
perror(__FILE__ ":vlogerr(): fprintf() < 0");
}
-
- return;
}
diff --git a/src/logerr.h b/src/logerr.h
index 56b2432..736da7a 100644
--- a/src/logerr.h
+++ b/src/logerr.h
@@ -1,3 +1,7 @@
+#define logerr(...) vlogerr(__FILE__, __func__, __LINE__, stderr, __VA_ARGS__)
+
+
+
void
vlogerr(
@@ -8,5 +12,3 @@ vlogerr(
const char *restrict format,
...
);
-
-#define logerr(...) vlogerr(__FILE__, __func__, __LINE__, stderr, __VA_ARGS__)
diff --git a/tests/logerr.c b/tests/logerr.c
index 3eef2c5..8ae1140 100644
--- a/tests/logerr.c
+++ b/tests/logerr.c
@@ -9,9 +9,12 @@
#include "slurp.h"
+
static const char *const
FNAME = __FILE__ ".txt";
+
+
static int
test_vlogerr(void) {
int rc = -1;
@@ -24,7 +27,7 @@ test_vlogerr(void) {
testing("empty varargs");
file = fopen(FNAME, "w");
- if (!file) {
+ if (file == NULL) {
perror("fopen(FNAME, \"w\")");
goto out;
}
@@ -57,7 +60,7 @@ test_vlogerr(void) {
testing("a newline only");
file = fopen(FNAME, "w");
- if (!file) {
+ if (file == NULL) {
perror("fopen(FNAME, \"w\")");
goto out;
}
@@ -90,7 +93,7 @@ test_vlogerr(void) {
testing("static format string");
file = fopen(FNAME, "w");
- if (!file) {
+ if (file == NULL) {
perror("fopen(FNAME, \"w\")");
goto out;
}
@@ -123,7 +126,7 @@ test_vlogerr(void) {
testing("single arg format string");
file = fopen(FNAME, "w");
- if (!file) {
+ if (file == NULL) {
perror("fopen(FNAME, \"w\")");
goto out;
}
@@ -156,7 +159,7 @@ test_vlogerr(void) {
testing("multiple format strings");
file = fopen(FNAME, "w");
- if (!file) {
+ if (file == NULL) {
perror("fopen(FNAME, \"w\")");
goto out;
}
@@ -195,7 +198,7 @@ out:
if (str != NULL) {
freeit((void *)&str);
}
- if (file) {
+ if (file != NULL) {
if (fclose(file)) {
perror("fclose(file)");
rc = -1;
@@ -204,10 +207,8 @@ out:
return rc;
}
-static int
+static void
test_logerr(void) {
- int rc = -1;
-
test_start("logerr()");
{
@@ -238,9 +239,6 @@ test_logerr(void) {
test_ok();
}
-
- rc = 0;
- return rc;
}
@@ -253,10 +251,7 @@ main(void) {
goto out;
}
- if (test_logerr()) {
- perror("test_logerr()");
- goto out;
- }
+ test_logerr();
rc = EXIT_SUCCESS;
out: