subversion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bert Huijben" <b...@qqmail.nl>
Subject RE: svn commit: r1728324 - /subversion/trunk/subversion/tests/svn_test_main.c
Date Thu, 04 Feb 2016 11:38:54 GMT


> -----Original Message-----
> From: philip@apache.org [mailto:philip@apache.org]
> Sent: woensdag 3 februari 2016 15:27
> To: commits@subversion.apache.org
> Subject: svn commit: r1728324 -
> /subversion/trunk/subversion/tests/svn_test_main.c
> 
> Author: philip
> Date: Wed Feb  3 14:27:01 2016
> New Revision: 1728324
> 
> URL: http://svn.apache.org/viewvc?rev=1728324&view=rev
> Log:
> * subversion/tests/svn_test_main.c
>   (call_setjmp): New, to fix some potential setjmp/longjmp clobbers.
>   (do_test_num): Call new function, tweak comment to explain why
>    a parameter is modified.
> 
> Modified:
>     subversion/trunk/subversion/tests/svn_test_main.c
> 
> Modified: subversion/trunk/subversion/tests/svn_test_main.c
> URL:
> http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test
> _main.c?rev=1728324&r1=1728323&r2=1728324&view=diff
> ==========================================================
> ====================
> --- subversion/trunk/subversion/tests/svn_test_main.c (original)
> +++ subversion/trunk/subversion/tests/svn_test_main.c Wed Feb  3
> 14:27:01 2016
> @@ -393,6 +393,16 @@ log_results(const char *progname,
>    return test_failed;
>  }
> 
> +/* This function exists so that automatic variables in the calling
> +   function are peserved.  At the time of writing 'err' and 'test_num'
> +   in 'do_test_num()' were in danger of being clobbered by a direct
> +   setjmp() call. */
> +static int call_setjmp(jmp_buf env)
> +{
> +  return setjmp(env);

I don't think this is allowed.

Setjmp is not really a function that you can just call from an inner function. As a macro
it stores the current stack state, to allow a later return by resetting the stack to the old
state. With an inner function this is not guaranteed to work. (I'm guessing many compilers
would just inline the single call, but then...)

	Bert 



Mime
View raw message