Message ID | 20190924200902.4703-6-vsementsov@virtuozzo.com |
---|---|
State | New |
Headers | show |
Series | error: auto propagated local_err | expand |
On 9/24/19 3:08 PM, Vladimir Sementsov-Ogievskiy wrote: > error_append_hint will not work, if errp == &fatal_error, as program > will exit before error_append_hint call. Fix this by use of special > macro ERRP_FUNCTION_BEGIN. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> > --- With the approach of a partial cleanup (rather than globally enforcing it for all functions with errp parameter), we'll probably be rerunning this Coccinelle script regularly, to track down any regressions. > +++ b/scripts/coccinelle/fix-error_append_hint-usage.cocci > @@ -0,0 +1,25 @@ > +@rule0@ > +// Add invocation to errp-functions > +identifier fn; > +@@ > + > + fn(..., Error **errp, ...) > + { > ++ ERRP_FUNCTION_BEGIN(); > + <+... > + error_append_hint(errp, ...); > + ...+> > + } Does not catch the case that we want to also use the macro for any use of *errp, but we can augment that later. > + > +@@ > +// Drop doubled invocation > +identifier rule0.fn; > +@@ > + > + fn(...) > +{ > + ERRP_FUNCTION_BEGIN(); > +- ERRP_FUNCTION_BEGIN(); > + ... > +} This is smaller than the script you posted in v2, and thus I'm a bit more confident in stating that it looks correct and idempotent. Reviewed-by: Eric Blake <eblake@redhat.com>
On 9/24/19 3:08 PM, Vladimir Sementsov-Ogievskiy wrote: > error_append_hint will not work, if errp == &fatal_error, as program > will exit before error_append_hint call. Fix this by use of special > macro ERRP_FUNCTION_BEGIN. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> > --- > .../fix-error_append_hint-usage.cocci | 25 +++++++++++++++++++ > 1 file changed, 25 insertions(+) > create mode 100644 scripts/coccinelle/fix-error_append_hint-usage.cocci > > +} > + > Why are you creating a file with a trailing blank line?
24.09.2019 23:48, Eric Blake wrote: > On 9/24/19 3:08 PM, Vladimir Sementsov-Ogievskiy wrote: >> error_append_hint will not work, if errp == &fatal_error, as program >> will exit before error_append_hint call. Fix this by use of special >> macro ERRP_FUNCTION_BEGIN. >> >> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> >> --- > > With the approach of a partial cleanup (rather than globally enforcing > it for all functions with errp parameter), we'll probably be rerunning > this Coccinelle script regularly, to track down any regressions. > > >> +++ b/scripts/coccinelle/fix-error_append_hint-usage.cocci >> @@ -0,0 +1,25 @@ >> +@rule0@ >> +// Add invocation to errp-functions >> +identifier fn; >> +@@ >> + >> + fn(..., Error **errp, ...) >> + { >> ++ ERRP_FUNCTION_BEGIN(); >> + <+... >> + error_append_hint(errp, ...); >> + ...+> >> + } > > Does not catch the case that we want to also use the macro for any use > of *errp, but we can augment that later. I don't want to include *errp here, as actually a lot of *errp invocations in code are correct: they do it if errp is not NULL. So, it's not related to plan B. Still, I think we forget about error_prepend :))) I've checked, if I include error_prepend here, series becomes 30 patches, which is not significantly larger. So I think, I'll cover error_prepend in v4. > >> + >> +@@ >> +// Drop doubled invocation >> +identifier rule0.fn; >> +@@ >> + >> + fn(...) >> +{ >> + ERRP_FUNCTION_BEGIN(); >> +- ERRP_FUNCTION_BEGIN(); >> + ... >> +} > > This is smaller than the script you posted in v2, and thus I'm a bit > more confident in stating that it looks correct and idempotent. > > Reviewed-by: Eric Blake <eblake@redhat.com> >
diff --git a/scripts/coccinelle/fix-error_append_hint-usage.cocci b/scripts/coccinelle/fix-error_append_hint-usage.cocci new file mode 100644 index 0000000000..327fe6098c --- /dev/null +++ b/scripts/coccinelle/fix-error_append_hint-usage.cocci @@ -0,0 +1,25 @@ +@rule0@ +// Add invocation to errp-functions +identifier fn; +@@ + + fn(..., Error **errp, ...) + { ++ ERRP_FUNCTION_BEGIN(); + <+... + error_append_hint(errp, ...); + ...+> + } + +@@ +// Drop doubled invocation +identifier rule0.fn; +@@ + + fn(...) +{ + ERRP_FUNCTION_BEGIN(); +- ERRP_FUNCTION_BEGIN(); + ... +} +
error_append_hint will not work, if errp == &fatal_error, as program will exit before error_append_hint call. Fix this by use of special macro ERRP_FUNCTION_BEGIN. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> --- CC: John Snow <jsnow@redhat.com> CC: Kevin Wolf <kwolf@redhat.com> CC: Max Reitz <mreitz@redhat.com> CC: Fam Zheng <fam@euphon.net> CC: Jeff Cody <codyprime@gmail.com> CC: "Marc-André Lureau" <marcandre.lureau@redhat.com> CC: Paolo Bonzini <pbonzini@redhat.com> CC: Greg Kurz <groug@kaod.org> CC: Subbaraya Sundeep <sundeep.lkml@gmail.com> CC: Peter Maydell <peter.maydell@linaro.org> CC: Paul Burton <pburton@wavecomp.com> CC: Aleksandar Rikalo <arikalo@wavecomp.com> CC: "Michael S. Tsirkin" <mst@redhat.com> CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> CC: David Gibson <david@gibson.dropbear.id.au> CC: Yuval Shaia <yuval.shaia@oracle.com> CC: Cornelia Huck <cohuck@redhat.com> CC: Eric Farman <farman@linux.ibm.com> CC: Richard Henderson <rth@twiddle.net> CC: David Hildenbrand <david@redhat.com> CC: Halil Pasic <pasic@linux.ibm.com> CC: Christian Borntraeger <borntraeger@de.ibm.com> CC: Gerd Hoffmann <kraxel@redhat.com> CC: Alex Williamson <alex.williamson@redhat.com> CC: Markus Armbruster <armbru@redhat.com> CC: Michael Roth <mdroth@linux.vnet.ibm.com> CC: Juan Quintela <quintela@redhat.com> CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com> CC: Eric Blake <eblake@redhat.com> CC: Jason Wang <jasowang@redhat.com> CC: "Daniel P. Berrangé" <berrange@redhat.com> CC: Eduardo Habkost <ehabkost@redhat.com> CC: qemu-block@nongnu.org CC: qemu-devel@nongnu.org CC: integration@gluster.org CC: qemu-arm@nongnu.org CC: qemu-ppc@nongnu.org CC: qemu-s390x@nongnu.org .../fix-error_append_hint-usage.cocci | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 scripts/coccinelle/fix-error_append_hint-usage.cocci