diff options
author | EuAndreh <eu@euandre.org> | 2024-06-12 10:39:48 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-06-12 10:49:37 -0300 |
commit | 8b0cd0dfcceb3aee49d3cab703a718cc56867f98 (patch) | |
tree | f352d41ac5f1206ec8b56e51de9efbd28918cb4f | |
parent | tests/set.c: Add broken test for HASH_OUTPUT_LENGTH (diff) | |
download | pindaiba-8b0cd0dfcceb3aee49d3cab703a718cc56867f98.tar.gz pindaiba-8b0cd0dfcceb3aee49d3cab703a718cc56867f98.tar.xz |
src/logerr.h: Normalize code order
-rw-r--r-- | src/logerr.c | 3 | ||||
-rw-r--r-- | src/logerr.h | 6 | ||||
-rw-r--r-- | tests/logerr.c | 27 |
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: |