]> sourceware.org Git - lvm2.git/commitdiff
libdm: enclose dm_stats_walk_do/while() body in do..while
authorBryn M. Reeves <bmr@redhat.com>
Thu, 7 Jul 2016 20:28:35 +0000 (21:28 +0100)
committerBryn M. Reeves <bmr@redhat.com>
Fri, 8 Jul 2016 10:14:22 +0000 (11:14 +0100)
The call to dm_stats_walk_start() before the do statement makes
dm_stats_walk_do() behave inconsistently depending on context;
wrap them in an additional do { } while (0) so that the macro
always expands to a valid statement.

libdm/libdevmapper.h

index 415928ccf13fb4954bd1af46363a5a554965c5fe..ec644260c946bc6d047dc4e41068194d1238c019 100644 (file)
@@ -1146,15 +1146,17 @@ for (dm_stats_walk_init((dms), DM_STATS_WALK_GROUP),            \
  * empty.
  */
 #define dm_stats_walk_do(dms)                                  \
-dm_stats_walk_start((dms));                                    \
-do
+do {                                                           \
+       dm_stats_walk_start((dms));                             \
+       do
 
 /*
  * Start a 'while' style loop or end a 'do..while' loop iterating over the
  * regions contained in dm_stats handle 'dms'.
  */
 #define dm_stats_walk_while(dms)                               \
-while(!dm_stats_walk_end((dms)))
+       while(!dm_stats_walk_end((dms)));                       \
+} while (0)
 
 /*
  * Cursor relative property methods
This page took 0.084888 seconds and 5 git commands to generate.