]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
debug: Link __UL_DBG_ macros together
authorTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 3 Apr 2026 09:08:36 +0000 (11:08 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 7 Apr 2026 10:09:29 +0000 (12:09 +0200)
__UL_DBG_CALL can be used by __UL_DBG_OBJ which can be used by __UL_DBG,
which puts the flag check into a single line without duplications.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
include/debug.h

index 6f86224c2c308836a89457003eee295268a9243e..3e3e76ed23934c5576ebef8243bac02d5e9f85b4 100644 (file)
@@ -71,24 +71,22 @@ struct ul_debug_maskname {
 #define __UL_DEBUG_FL_NOADDR   (1 << 24)       /* Don't print object address */
 
 
-#define __UL_DBG_OBJ(lib, pref, flag, h, x) \
+#define __UL_DBG_CALL(lib, pref, flag, x) \
        do { \
                if ((pref ## flag) & UL_DEBUG_MASK(lib)) { \
-                       ul_debug_prefix(# lib, # flag, h, UL_DEBUG_MASK(lib)); \
                        x; \
                } \
        } while (0)
 
+#define __UL_DBG_OBJ(lib, pref, flag, h, x) \
+       __UL_DBG_CALL(lib, pref, flag, { \
+               ul_debug_prefix(# lib, # flag, h, UL_DEBUG_MASK(lib)); \
+               x; \
+       })
+
 #define __UL_DBG(lib, pref, flag, x) \
        __UL_DBG_OBJ(lib, pref, flag, NULL, x)
 
-#define __UL_DBG_CALL(lib, pref, flag, x) \
-       do { \
-               if ((pref ## flag) & UL_DEBUG_MASK(lib)) { \
-                       x; \
-               } \
-       } while (0)
-
 #define __UL_DBG_FLUSH(lib, pref) \
        do { \
                if (UL_DEBUG_MASK(lib) && UL_DEBUG_MASK(lib) != pref ## INIT) { \