Re: [hackers][sbase][PATCH] Activate the "else if" branch
Heyho
On Wed, Dec 16, 2015 at 9:28 AM, Roberto E. Vargas Caballero
<k0ga_AT_shike2.com> wrote:
> On Tue, Dec 15, 2015 at 07:54:28PM +0100, Silvan Jegen wrote:
>> We checked the same condition in the "if" branch so it was never true
>> in the "else if" one. Removing this condition makes the "else if"
>> branch viable.
>
> I'm sorry, but you are wrong here. Setjmp saves the current state
No need to be sorry I am wrong all the time :P
> of the program, and it allows that a deeper call to longjmp restores
> the state. When setjmp is called directly it returns always 0,
> but when it returns dur to a call to longjmp it returns a value
> passed as parameter to longjmp (in our case 1). It is a kind of
> try {} catch{} ala C.
>
>> dowrite("ed.hup", 1);
>> - } else if (home && !setjmp(savesp)) {
>> + } else if (home) {
>> n = snprintf(fname,
>
> If you remove the setjmp in the else if branch, then any call
> to error (which calls to longjmp) will resume the execution in
> the if branch, making a new execution of the else if branch,
> which in some cases will produce an infinite loop.
That means that the "else if" clause should only run when setjmp
returns directly and not due to a call to longjmp.
I wasn't considering the side effects of calling setjmp so ignore this
patch. Thanks for the feedback!
Cheers,
Silvan
Received on Wed Dec 16 2015 - 11:00:15 CET
This archive was generated by hypermail 2.3.0
: Wed Dec 16 2015 - 11:12:12 CET