@@ -32,14 +32,21 @@
#define MAX(x,y) (x > y) ? x : y
#define TAIL (line + len - 1 - c)
#define NOPAD s = c
-#define PAD(x) while ((int)(c - s) < (x) && (c < (line + len - 1))) \
- *c++ = ' '; s = c
+#define PAD(x) \
+do { \
+ while ((int)(c - s) < (x) && (c < (line + len - 1))) \
+ *c++ = ' '; \
+ s = c; \
+} while (0)
+
#define ENDLINE \
if (c > line) \
line[c - line - 1] = '\n'
-#define PRINT(var, size, format, args...) \
- fwd = snprintf(var, size, format, ##args); \
- c += (fwd >= size) ? size : fwd;
+#define PRINT(var, size, format, args...) \
+do { \
+ fwd = snprintf(var, size, format, ##args); \
+ c += (fwd >= size) ? size : fwd; \
+} while (0)
/*
* information printing helpers
The PAD and PRINT macros are multi-line macros that aren't enclosed in braces. This means that if they are used as single line code blocks with no braces, they won't work correctly. This is currently happening with the PAD macro, but should be fixed in both. Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> --- libmultipath/print.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)