Module Name:    src
Committed By:   rillig
Date:           Sun Dec  6 10:33:42 UTC 2020

Modified Files:
        src/usr.bin/make: make.h

Log Message:
make(1): clean up macros for debug logging

Using a do-while loop prevents compiler warnings about possible dangling
else.  It also removes the unnecessary negation.


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/usr.bin/make/make.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.231 src/usr.bin/make/make.h:1.232
--- src/usr.bin/make/make.h:1.231	Sat Dec  5 18:38:02 2020
+++ src/usr.bin/make/make.h	Sun Dec  6 10:33:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.231 2020/12/05 18:38:02 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.232 2020/12/06 10:33:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -581,29 +581,24 @@ typedef enum DebugFlags {
 
 void debug_printf(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
 
-#define DEBUG0(module, text) \
-    if (!DEBUG(module)) (void)0; \
-    else debug_printf("%s", text)
+#define DEBUG_IMPL(module, args) \
+	do { \
+		if (DEBUG(module)) \
+			debug_printf args; \
+	} while (0)
 
+#define DEBUG0(module, text) \
+	DEBUG_IMPL(module, ("%s", text))
 #define DEBUG1(module, fmt, arg1) \
-    if (!DEBUG(module)) (void)0; \
-    else debug_printf(fmt, arg1)
-
+	DEBUG_IMPL(module, (fmt, arg1))
 #define DEBUG2(module, fmt, arg1, arg2) \
-    if (!DEBUG(module)) (void)0; \
-    else debug_printf(fmt, arg1, arg2)
-
+	DEBUG_IMPL(module, (fmt, arg1, arg2))
 #define DEBUG3(module, fmt, arg1, arg2, arg3) \
-    if (!DEBUG(module)) (void)0; \
-    else debug_printf(fmt, arg1, arg2, arg3)
-
+	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3))
 #define DEBUG4(module, fmt, arg1, arg2, arg3, arg4) \
-    if (!DEBUG(module)) (void)0; \
-    else debug_printf(fmt, arg1, arg2, arg3, arg4)
-
+	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4))
 #define DEBUG5(module, fmt, arg1, arg2, arg3, arg4, arg5) \
-    if (!DEBUG(module)) (void)0; \
-    else debug_printf(fmt, arg1, arg2, arg3, arg4, arg5)
+	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4, arg5))
 
 typedef enum PrintVarsMode {
 	PVM_NONE,

Reply via email to