Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): clean up macros for debug logging
details: https://anonhg.NetBSD.org/src/rev/03c065238393
branches: trunk
changeset: 946688:03c065238393
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Dec 06 10:33:42 2020 +0000
description:
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.
diffstat:
usr.bin/make/make.h | 35 +++++++++++++++--------------------
1 files changed, 15 insertions(+), 20 deletions(-)
diffs (53 lines):
diff -r 6ab855388124 -r 03c065238393 usr.bin/make/make.h
--- a/usr.bin/make/make.h Sun Dec 06 10:09:36 2020 +0000
+++ b/usr.bin/make/make.h Sun Dec 06 10:33:42 2020 +0000
@@ -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 @@
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 DEBUG1(module, fmt, arg1) \
- if (!DEBUG(module)) (void)0; \
- else debug_printf(fmt, arg1)
-
-#define DEBUG2(module, fmt, arg1, arg2) \
- if (!DEBUG(module)) (void)0; \
- else debug_printf(fmt, arg1, arg2)
+#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) \
+ DEBUG_IMPL(module, (fmt, arg1))
+#define DEBUG2(module, 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,
Home |
Main Index |
Thread Index |
Old Index