From: Bruno Haible Date: Tue, 20 Sep 2011 01:16:18 +0000 (+0200) Subject: msvc-inval: Require a semicolon after DONE_MSVC_INVAL. X-Git-Tag: v0.1~1859 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=cbf58f79a5541f258ec5e3b1e42c5f5579fce579;p=gnulib.git 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 index 3f4b62fed..eed69ce1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 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. * m4/sched_h.m4 (gl_SCHED_H): Arrange to override if it does not define pid_t. diff --git a/lib/dup2.c b/lib/dup2.c index 09ae49fb3..234bdfe50 100644 --- a/lib/dup2.c +++ b/lib/dup2.c @@ -57,7 +57,7 @@ rpl_dup2 (int fd, int desired_fd) { handle = INVALID_HANDLE_VALUE; } - DONE_MSVC_INVAL + DONE_MSVC_INVAL; if (handle == INVALID_HANDLE_VALUE) { @@ -88,7 +88,7 @@ rpl_dup2 (int fd, int desired_fd) 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 index 61f0f4667..65df0028d 100644 --- 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 @@ extern void gl_msvc_inval_ensure_handler (void); # 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 @@ extern void cdecl gl_msvc_invalid_parameter_handler (const wchar_t *expression, # 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 @@ extern void cdecl gl_msvc_invalid_parameter_handler (const wchar_t *expression, /* 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