Hi David,

On Mon, May 18, 2020 at 11:09:18AM -0400, David Malcolm wrote:
> On Mon, 2020-05-18 at 16:47 +0200, Mark Wielaard wrote:
> > On Mon, May 18, 2020 at 08:45:36AM -0400, David Malcolm wrote:
> > > Also, m_unsafe_fndecl is a field of signal_unsafe_call, so we can
> > > delay
> > > calling replacement_fn until inside signal_unsafe_call::emit, after
> > > the
> > > warning has been emitted.
> > > 
> > > It could even become a member function of signal_unsafe_call,
> > > giving
> > > something like this for signal_unsafe_call::emit:
> > 
> > Thanks for all the hints. I adopted all your suggestions and the
> > warning plus note now looks like:
> > [...] 
> > bzip2.c:874:4: note: ‘_exit’ is a possible signal-safe alternative
> > for ‘exit’
> >   874 |    exit(exitValue);
> >       |    ^~~~~~~~~~~~~~~
> >       |    _exit
> > 
> > I also added a testcase. How about the attached?
> 
> Overall, I like it, but it looks like there's a problem with the
> location of the fix-it hint: it looks like it might be replacing the
> whole of the underlined section of the call, argument, parentheses and
> all, with "_exit", rather than just the "exit" token.  I wonder if the
> location of that token is still available in the middle-end by the time
> the analyzer runs.
> 
> What does -fdiagnostics-generate-patch emit?

--- bzip2.c
+++ bzip2.c
@@ -871,7 +871,7 @@
       terribly wrong. Trying to clean up might fail spectacularly. */
 
    if (opMode == OM_Z) setExit(3); else setExit(2);
-   exit(exitValue);
+   _exit;
 }

Hmmm, back to the drawing board it seems.

Thanks,

Mark

Reply via email to