From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Markus Armbruster" <armbru@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Michael Roth" <mdroth@linux.vnet.ibm.com>
Subject: [PATCH-for-5.1 v3 7/7] qga/commands-win32: Add missing error-propagation code
Date: Mon, 13 Apr 2020 22:40:35 +0200 [thread overview]
Message-ID: <20200413204036.30757-1-f4bug@amsat.org> (raw)
In-Reply-To: 20200412224517.12869-1-f4bug@amsat.org
Running the coccinelle script produced:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/find-missing-error_propagate.cocci \
--keep-comments --smpl-spacing --dir .
HANDLING: ./qga/commands-win32.c
[[manual check required: error_propagate() might be missing in acquire_privilege() ./qga/commands-win32.c:1344:4]]
[[manual check required: error_propagate() might be missing in acquire_privilege() ./qga/commands-win32.c:1360:4]]
[[manual check required: error_propagate() might be missing in check_suspend_mode() ./qga/commands-win32.c:1343:4]]
[[manual check required: error_propagate() might be missing in check_suspend_mode() ./qga/commands-win32.c:1359:4]]
Add the missing error_propagate() after review.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
.../use-error_abort-in-instance_init.cocci | 17 ++++--------
qga/commands-win32.c | 26 +++++++++++++------
2 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/scripts/coccinelle/use-error_abort-in-instance_init.cocci b/scripts/coccinelle/use-error_abort-in-instance_init.cocci
index 8302d74a0c..706c60163c 100644
--- a/scripts/coccinelle/use-error_abort-in-instance_init.cocci
+++ b/scripts/coccinelle/use-error_abort-in-instance_init.cocci
@@ -24,29 +24,22 @@ identifier instance_initfn;
info.instance_init = instance_initfn;
-@ use_error_abort @
+@ use_error_abort_in_instance_init @
identifier match_instance_init.instance_initfn;
-identifier func_with_error;
-expression parentobj, propname, childobj, size, type, errp;
+identifier func_with_error != {qbus_create_inplace, object_initialize_child};
position pos;
@@
void instance_initfn(...)
{
<+...
-(
- object_initialize_child(parentobj, propname,
- childobj, size, type,
- errp, NULL);
-|
func_with_error@pos(...,
- NULL);
+ &error_abort);
-)
...+>
}
-@script:python depends on use_error_abort && !has_qapi_error@
-p << use_error_abort.pos;
+@ depends on use_error_abort_in_instance_init && !has_qapi_error @
@@
-print('[[manual edit required, %s misses #include "qapi/error.h"]]' % p[0].file)
+ #include ...
++ #include "qapi/error.h"
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index b49920e201..8b66098056 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -1341,13 +1341,18 @@ void qmp_guest_suspend_disk(Error **errp)
*mode = GUEST_SUSPEND_MODE_DISK;
check_suspend_mode(*mode, &local_err);
+ if (local_err) {
+ goto out;
+ }
acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
+ if (local_err) {
+ goto out;
+ }
execute_async(do_suspend, mode, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- g_free(mode);
- }
+out:
+ error_propagate(errp, local_err);
+ g_free(mode);
}
void qmp_guest_suspend_ram(Error **errp)
@@ -1357,13 +1362,18 @@ void qmp_guest_suspend_ram(Error **errp)
*mode = GUEST_SUSPEND_MODE_RAM;
check_suspend_mode(*mode, &local_err);
+ if (local_err) {
+ goto out;
+ }
acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
+ if (local_err) {
+ goto out;
+ }
execute_async(do_suspend, mode, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- g_free(mode);
- }
+out:
+ error_propagate(errp, local_err);
+ g_free(mode);
}
void qmp_guest_suspend_hybrid(Error **errp)
--
2.21.1
reply other threads:[~2020-04-13 20:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200413204036.30757-1-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=armbru@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).