On Tue, Oct 20, 2015 at 3:55 PM, Ilya Kaliman <ilya.kali...@gmail.com> wrote: ... > --- bin/ed/main.c 9 Oct 2015 21:24:05 -0000 1.53 > +++ bin/ed/main.c 20 Oct 2015 22:49:53 -0000 > @@ -174,7 +174,7 @@ top: > signal(SIGHUP, signal_hup); > signal(SIGQUIT, SIG_IGN); > signal(SIGINT, signal_int); > - if (status = sigsetjmp(env, 1)) { > + if ((status = sigsetjmp(env, 1))) {
This technically undefined behavior, as you are not allowed to capture the return value of setjmp(), _setjmp(), or sigsetjmp() in a variable To quote the C standard: ---- An application shall ensure that an invocation of setjmp( ) appears in one of the following contexts only: · The entire controlling expression of a selection or iteration statement · One operand of a relational or equality operator with the other operand an integral constant expression, with the resulting expression being the entire controlling expression of a selection or iteration statement · The operand of a unary '!' operator with the resulting expression being the entire controlling expression of a selection or iteration · The entire expression of an expression statement (possibly cast to void) If the invocation appears in any other context, the behavior is undefined. ---- POSIX extends that to the other two functions. Fortunately, ed only call sigsetjmpt() with the value -1, and status is initialized to zero, so the diff below should fix it without changing the behavior. oks? Philip Guenther --- bin/ed/main.c 21 Oct 2015 16:06:57 -0000 1.54 +++ bin/ed/main.c 23 Oct 2015 04:55:31 -0000 @@ -174,7 +174,8 @@ top: signal(SIGHUP, signal_hup); signal(SIGQUIT, SIG_IGN); signal(SIGINT, signal_int); - if ((status = sigsetjmp(env, 1))) { + if (sigsetjmp(env, 1)) { + status = -1; fputs("\n?\n", stderr); seterrmsg("interrupt"); } else {