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 <[email protected]> --- CC: John Snow <[email protected]> CC: Kevin Wolf <[email protected]> CC: Max Reitz <[email protected]> CC: Fam Zheng <[email protected]> CC: Jeff Cody <[email protected]> CC: "Marc-André Lureau" <[email protected]> CC: Paolo Bonzini <[email protected]> CC: Greg Kurz <[email protected]> CC: Subbaraya Sundeep <[email protected]> CC: Peter Maydell <[email protected]> CC: Paul Burton <[email protected]> CC: Aleksandar Rikalo <[email protected]> CC: "Michael S. Tsirkin" <[email protected]> CC: Marcel Apfelbaum <[email protected]> CC: Mark Cave-Ayland <[email protected]> CC: David Gibson <[email protected]> CC: Yuval Shaia <[email protected]> CC: Cornelia Huck <[email protected]> CC: Eric Farman <[email protected]> CC: Richard Henderson <[email protected]> CC: David Hildenbrand <[email protected]> CC: Halil Pasic <[email protected]> CC: Christian Borntraeger <[email protected]> CC: Gerd Hoffmann <[email protected]> CC: Alex Williamson <[email protected]> CC: Markus Armbruster <[email protected]> CC: Michael Roth <[email protected]> CC: Juan Quintela <[email protected]> CC: "Dr. David Alan Gilbert" <[email protected]> CC: Eric Blake <[email protected]> CC: Jason Wang <[email protected]> CC: "Daniel P. Berrangé" <[email protected]> CC: Eduardo Habkost <[email protected]> CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] .../fix-error_append_hint-usage.cocci | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 scripts/coccinelle/fix-error_append_hint-usage.cocci 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(); + ... +} + -- 2.21.0
