# HG changeset patch # User Bruno Haible # Date 1316481378 -7200 # Node ID df3eb2f0f1e891547a9fb5622363110ab7db01b6 # Parent bbe6ab59b982085c6a5f4f2378297be9c18ae881 msvc-inval: Require a semicolon after DONE_MSVC_INVAL. * lib/msvc-inval.h (TRY_MSVC_INVAL, DONE_MSVC_INVAL): Wrap in a do...while(0). * lib/dup2.c (rpl_dup2): Add a semicolon after DONE_MSVC_INVAL. Suggested by Paul Eggert. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-09-19 Bruno Haible + + msvc-inval: Require a semicolon after DONE_MSVC_INVAL. + * lib/msvc-inval.h (TRY_MSVC_INVAL, DONE_MSVC_INVAL): Wrap in a + do...while(0). + * lib/dup2.c (rpl_dup2): Add a semicolon after DONE_MSVC_INVAL. + Suggested by Paul Eggert. + 2011-09-19 Bruno Haible sched: Ensure pid_t is defined. diff --git a/lib/dup2.c b/lib/dup2.c --- a/lib/dup2.c +++ b/lib/dup2.c @@ -57,7 +57,7 @@ { handle = INVALID_HANDLE_VALUE; } - DONE_MSVC_INVAL + DONE_MSVC_INVAL; if (handle == INVALID_HANDLE_VALUE) { @@ -88,7 +88,7 @@ result = -1; errno = EBADF; } - DONE_MSVC_INVAL + DONE_MSVC_INVAL; # ifdef __linux__ /* Correct a Linux return value. diff --git a/lib/msvc-inval.h b/lib/msvc-inval.h --- a/lib/msvc-inval.h +++ b/lib/msvc-inval.h @@ -36,7 +36,7 @@ } - DONE_MSVC_INVAL + DONE_MSVC_INVAL; This entire block expands to a single statement. */ @@ -79,15 +79,17 @@ # endif # define TRY_MSVC_INVAL \ - { \ - gl_msvc_inval_ensure_handler (); \ - __try + do \ + { \ + gl_msvc_inval_ensure_handler (); \ + __try # define CATCH_MSVC_INVAL \ - __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER \ - ? EXCEPTION_EXECUTE_HANDLER \ - : EXCEPTION_CONTINUE_SEARCH) + __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER \ + ? EXCEPTION_EXECUTE_HANDLER \ + : EXCEPTION_CONTINUE_SEARCH) # define DONE_MSVC_INVAL \ - } + } \ + while (0) # else /* Any compiler. @@ -119,27 +121,29 @@ # endif # define TRY_MSVC_INVAL \ - { \ - _invalid_parameter_handler orig_handler; \ - /* First, initialize gl_msvc_inval_restart. */ \ - if (setjmp (gl_msvc_inval_restart) == 0) \ - { \ - /* Then, enable gl_msvc_invalid_parameter_handler. */ \ - orig_handler = \ - _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler); + do \ + { \ + _invalid_parameter_handler orig_handler; \ + /* First, initialize gl_msvc_inval_restart. */ \ + if (setjmp (gl_msvc_inval_restart) == 0) \ + { \ + /* Then, enable gl_msvc_invalid_parameter_handler. */ \ + orig_handler = \ + _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler); # define CATCH_MSVC_INVAL \ - /* Execution completed. \ - Disable gl_msvc_invalid_parameter_handler. */ \ - _set_invalid_parameter_handler (orig_handler); \ - } \ - else \ - { \ - /* Execution triggered an invalid parameter notification. \ - Disable gl_msvc_invalid_parameter_handler. */ \ - _set_invalid_parameter_handler (orig_handler); + /* Execution completed. \ + Disable gl_msvc_invalid_parameter_handler. */ \ + _set_invalid_parameter_handler (orig_handler); \ + } \ + else \ + { \ + /* Execution triggered an invalid parameter notification. \ + Disable gl_msvc_invalid_parameter_handler. */ \ + _set_invalid_parameter_handler (orig_handler); # define DONE_MSVC_INVAL \ - } \ - } + } \ + } \ + while (0) # endif @@ -148,9 +152,15 @@ /* The braces here avoid GCC warnings like "warning: suggest explicit braces to avoid ambiguous `else'". */ -# define TRY_MSVC_INVAL { if (1) -# define CATCH_MSVC_INVAL else -# define DONE_MSVC_INVAL } +# define TRY_MSVC_INVAL \ + do \ + { \ + if (1) +# define CATCH_MSVC_INVAL \ + else +# define DONE_MSVC_INVAL \ + } \ + while (0) #endif