On Thu, Jul 13, 2000 at 12:05:59PM -0000, gstein@tigris.org wrote:
>...
> Modified: subversion/libsvn_subr svn_error.h
> Log:
> tweak the macros so they bind properly within an enclosing if/else construct
>...
> --- svn_error.h 2000/07/13 05:12:34 1.14
> +++ svn_error.h 2000/07/13 12:05:58 1.15
> @@ -62,10 +62,10 @@
>
> /* REALLY USEFUL macros for throwing errors quickly and easily! */
> #define SVN_RETURN_IF_ERROR(err) \
> -if (err) return (err)
> + if (err) return (err); else
>
> #define SVN_RETURN_WRAPPED_ERROR(err, msg) \
> -if (err) return (svn_quick_wrap_error((err),(msg)))
> + if (err) return (svn_quick_wrap_error((err),(msg))); else
These changes were made to prevent problems such as:
if (whatever_test)
SVN_RETURN_IF_ERROR(err);
else
do_something();
Without the extra "else" in the macro, then the "else" in the above code
would bind to the "if (err)" inside the macro. The expanded form now looks
like:
if (whatever_test)
if (err)
return (err);
else
; /* the semicolon after SVN_RETURN_IF_ERROR() */
else
do_something();
Of course, all this would be avoided by always using braces in if/else
blocks. But programmers tend to drop them if a single statement follows.
Better be on the safe side and fix the macro...
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
Received on Sat Oct 21 14:36:05 2006