[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 9/9] ui: Reduce nesting in hmp_change_vnc() slightly
From: |
Markus Armbruster |
Subject: |
[PATCH 9/9] ui: Reduce nesting in hmp_change_vnc() slightly |
Date: |
Thu, 1 Dec 2022 07:13:11 +0100 |
Transform
if (good) {
do stuff
} else {
handle error
}
to
if (!good) {
handle error
return;
}
do stuff
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
ui/ui-hmp-cmds.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c
index b1b18d5a5d..31778122d3 100644
--- a/ui/ui-hmp-cmds.c
+++ b/ui/ui-hmp-cmds.c
@@ -287,19 +287,16 @@ void hmp_change_vnc(Monitor *mon, const char *device,
const char *target,
error_setg(errp, "Parameter 'read-only-mode' is invalid for VNC");
return;
}
- if (strcmp(target, "passwd") == 0 ||
- strcmp(target, "password") == 0) {
- if (!arg) {
- MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
- monitor_read_password(hmp_mon, hmp_change_read_arg, NULL);
- return;
- } else {
- qmp_change_vnc_password(arg, errp);
- }
- } else {
+ if (strcmp(target, "passwd") && strcmp(target, "password")) {
error_setg(errp, "Expected 'password' after 'vnc'");
return;
}
+ if (!arg) {
+ MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
+ monitor_read_password(hmp_mon, hmp_change_read_arg, NULL);
+ } else {
+ qmp_change_vnc_password(arg, errp);
+ }
}
#endif
--
2.37.3
- Re: [PATCH 2/9] ui: Fix silent truncation of numeric keys in HMP sendkey, (continued)
- [PATCH 7/9] ui: Improve "change vnc" error reporting, Markus Armbruster, 2022/12/01
- [PATCH 8/9] ui: Factor out hmp_change_vnc(), and move to ui/ui-hmp-cmds.c, Markus Armbruster, 2022/12/01
- [PATCH 6/9] ui: Move HMP commands from monitor to new ui/ui-hmp-cmds.c, Markus Armbruster, 2022/12/01
- [PATCH 9/9] ui: Reduce nesting in hmp_change_vnc() slightly,
Markus Armbruster <=
- [PATCH 5/9] ui: Move QMP commands from monitor to new ui/ui-qmp-cmds.c, Markus Armbruster, 2022/12/01