[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: svn commit: r1728324 - /subversion/trunk/subversion/tests/svn_test_main.c

From: Bert Huijben <bert_at_qqmail.nl>
Date: Thu, 4 Feb 2016 12:38:54 +0100

> -----Original Message-----
> From: philip_at_apache.org [mailto:philip_at_apache.org]
> Sent: woensdag 3 februari 2016 15:27
> To: commits_at_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
Received on 2016-02-04 12:39:06 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.