Semi-colon after if tweaks
Francois Gouget
fgouget at free.fr
Sun Sep 25 17:00:49 CDT 2005
I was grepping for some of the semi-colon after if issues and found
these two:
#define VIRTUAL_DEBUG_DUMP_VIEW(view) \
if (!TRACE_ON(virtual)); else VIRTUAL_DumpView(view)
#define debug_print_menuitem(pre, mp, post) \
if(!TRACE_ON(menu)) ; else do_debug_print_menuitem(pre, mp, post)
The code is correct and the reason for the 'if (!cond) ; else code'
construct is so that 'MACRO(xxx) else' will cause an error unless
there's an if right before 'MACRO'.
However it's a pretty unusual construct: it only happens twice in all of
Wine. I would feel better if the usual 'do { code } while (0)' construct
was used instead (already used 144+ times in Wine). this would also make
it possible to use 'standard' if. This would give us:
#define VIRTUAL_DEBUG_DUMP_VIEW(view) \
do { if (TRACE_ON(virtual)) VIRTUAL_DumpView(view); } while (0)
#define debug_print_menuitem(pre, mp, post) \
do { if (TRACE_ON(menu)) do_debug_print_menuitem(pre, mp, post); } while (0)
So here's the patch:
Changelog:
* dlls/ntdll/virtual.c
dlls/user/menu.c
Francois Gouget <fgouget at free.fr>
Replace the 'if (!cond) ; else code' construct with the standard 'do
{ code } while (0)' construct combined with a regular 'if'.
--
Francois Gouget fgouget at free.fr http://fgouget.free.fr/
Good judgment comes from experience, and experience comes from bad judgment
-- Barry LePatner
-------------- next part --------------
Index: dlls/ntdll/virtual.c
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/virtual.c,v
retrieving revision 1.70
diff -u -p -r1.70 virtual.c
--- dlls/ntdll/virtual.c 25 Sep 2005 15:23:21 -0000 1.70
+++ dlls/ntdll/virtual.c 25 Sep 2005 16:54:22 -0000
@@ -134,7 +134,7 @@ static const UINT_PTR granularity_mask =
(((UINT)(size) + ((UINT_PTR)(addr) & page_mask) + page_mask) & ~page_mask)
#define VIRTUAL_DEBUG_DUMP_VIEW(view) \
- if (!TRACE_ON(virtual)); else VIRTUAL_DumpView(view)
+ do { if (TRACE_ON(virtual)) VIRTUAL_DumpView(view); } while (0)
static void *user_space_limit = USER_SPACE_LIMIT;
Index: dlls/user/menu.c
===================================================================
RCS file: /var/cvs/wine/dlls/user/menu.c,v
retrieving revision 1.39
diff -u -p -r1.39 menu.c
--- dlls/user/menu.c 25 Sep 2005 15:23:21 -0000 1.39
+++ dlls/user/menu.c 25 Sep 2005 16:54:34 -0000
@@ -198,7 +198,7 @@ const struct builtin_class_descr MENU_bu
*/
#define debug_print_menuitem(pre, mp, post) \
- if(!TRACE_ON(menu)) ; else do_debug_print_menuitem(pre, mp, post)
+ do { if (TRACE_ON(menu)) do_debug_print_menuitem(pre, mp, post); } while (0)
#define MENUOUT(text) \
TRACE("%s%s", (count++ ? "," : ""), (text))
More information about the wine-patches
mailing list