* [PATCH-for-5.1 v3 7/7] qga/commands-win32: Add missing error-propagation code
@ 2020-04-13 20:40 Philippe Mathieu-Daudé
0 siblings, 0 replies; only message in thread
From: Philippe Mathieu-Daudé @ 2020-04-13 20:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Markus Armbruster, Philippe Mathieu-Daudé, Michael Roth
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-13 20:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-13 20:40 [PATCH-for-5.1 v3 7/7] qga/commands-win32: Add missing error-propagation code Philippe Mathieu-Daudé
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).