]> git.gsnw.org Git - fping.git/commitdiff
fix debug build use of dbg_printf in fping.c
authorErik Auerswald <auerswal@unix-ag.uni-kl.de>
Sat, 8 Mar 2025 19:02:53 +0000 (20:02 +0100)
committerErik Auerswald <auerswal@unix-ag.uni-kl.de>
Sun, 6 Apr 2025 15:24:15 +0000 (17:24 +0200)
config.h must be include before fping.h, because
configure --enable-debug writes the DEBUG #define
to config.h, and the dbg_printf macro definition
requires a defined DEBUG to actually produce any
output.

Unbreaking dbg_printf() exposed an instance of
wrong use, so fix that.  Also, add a newline to
the debug output reporting used CPU time.

src/fping.c

index a7acb2fb0e60c004424f9f775024e814659bf0e6..9aa527a78b569bb40ece6b498a504319bd631771 100644 (file)
@@ -34,8 +34,8 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#include "fping.h"
 #include "config.h"
+#include "fping.h"
 #include "options.h"
 #include "optparse.h"
 
@@ -1339,7 +1339,7 @@ int main(int argc, char **argv)
 #if defined(DEBUG) || defined(_DEBUG)
     perf_cpu_end = clock();
     perf_cpu_time_used = ((double) (perf_cpu_end - perf_cpu_start)) / CLOCKS_PER_SEC;
-    printf("[DEBUG] CPU time used: %f sec", perf_cpu_time_used);
+    printf("[DEBUG] CPU time used: %f sec\n", perf_cpu_time_used);
 #endif /* DEBUG || _DEBUG */
 
     finish();
@@ -2757,7 +2757,7 @@ int wait_for_reply(int64_t wait_time)
 
     /* optionally require reply source equal to target address */
     if (check_source_flag && addr_cmp((struct sockaddr *)&response_addr, (struct sockaddr *)&h->saddr)) {
-        dbg_printf("discarding reply from wrong source address\n");
+        dbg_printf("%s\n", "discarding reply from wrong source address");
         return 1;
     }