From: Bin Guo <guobin@linux.alibaba.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, berrange@redhat.com, kwolf@redhat.com,
hreitz@redhat.com, qemu-block@nongnu.org
Subject: [PATCH 3/3] system/vl.c: inline qemu_opts_parse_noisily() result checks
Date: Wed, 29 Apr 2026 14:20:04 +0800 [thread overview]
Message-ID: <20260429062004.36582-4-guobin@linux.alibaba.com> (raw)
In-Reply-To: <20260429062004.36582-1-guobin@linux.alibaba.com>
In qemu_init()'s option parsing switch, several cases assigned the
return value of qemu_opts_parse_noisily() to the shared 'opts'
variable solely to check for NULL, without using the pointer
afterwards. Inline the call directly into the if-condition, matching
the style already used by QEMU_OPTION_action.
This affects the following options:
-drive, -numa, -iscsi, -m, -mon, -chardev, -fsdev, -fwcfg
Cases where the returned QemuOpts* is subsequently used (e.g.
-acpitable, -smbios, -virtfs) are left unchanged.
Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
---
system/vl.c | 37 +++++++++++++++----------------------
1 file changed, 15 insertions(+), 22 deletions(-)
diff --git a/system/vl.c b/system/vl.c
index 0e1fc217b4..0e0d3cb761 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2961,9 +2961,8 @@ void qemu_init(int argc, char **argv)
break;
}
case QEMU_OPTION_drive:
- opts = qemu_opts_parse_noisily(qemu_find_opts("drive"),
- optarg, false);
- if (opts == NULL) {
+ if (!qemu_opts_parse_noisily(qemu_find_opts("drive"),
+ optarg, false)) {
exit(1);
}
break;
@@ -2988,9 +2987,8 @@ void qemu_init(int argc, char **argv)
replay_add_blocker("-snapshot");
break;
case QEMU_OPTION_numa:
- opts = qemu_opts_parse_noisily(qemu_find_opts("numa"),
- optarg, true);
- if (!opts) {
+ if (!qemu_opts_parse_noisily(qemu_find_opts("numa"),
+ optarg, true)) {
exit(1);
}
break;
@@ -3049,9 +3047,8 @@ void qemu_init(int argc, char **argv)
break;
#ifdef CONFIG_LIBISCSI
case QEMU_OPTION_iscsi:
- opts = qemu_opts_parse_noisily(qemu_find_opts("iscsi"),
- optarg, false);
- if (!opts) {
+ if (!qemu_opts_parse_noisily(qemu_find_opts("iscsi"),
+ optarg, false)) {
exit(1);
}
break;
@@ -3104,8 +3101,8 @@ void qemu_init(int argc, char **argv)
exit(0);
break;
case QEMU_OPTION_m:
- opts = qemu_opts_parse_noisily(qemu_find_opts("memory"), optarg, true);
- if (opts == NULL) {
+ if (!qemu_opts_parse_noisily(qemu_find_opts("memory"),
+ optarg, true)) {
exit(1);
}
break;
@@ -3226,17 +3223,15 @@ void qemu_init(int argc, char **argv)
default_monitor = 0;
break;
case QEMU_OPTION_mon:
- opts = qemu_opts_parse_noisily(qemu_find_opts("mon"), optarg,
- true);
- if (!opts) {
+ if (!qemu_opts_parse_noisily(qemu_find_opts("mon"), optarg,
+ true)) {
exit(1);
}
default_monitor = 0;
break;
case QEMU_OPTION_chardev:
- opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"),
- optarg, true);
- if (!opts) {
+ if (!qemu_opts_parse_noisily(qemu_find_opts("chardev"),
+ optarg, true)) {
exit(1);
}
break;
@@ -3246,8 +3241,7 @@ void qemu_init(int argc, char **argv)
error_report("fsdev support is disabled");
exit(1);
}
- opts = qemu_opts_parse_noisily(olist, optarg, true);
- if (!opts) {
+ if (!qemu_opts_parse_noisily(olist, optarg, true)) {
exit(1);
}
break;
@@ -3386,9 +3380,8 @@ void qemu_init(int argc, char **argv)
smbios_entry_add(opts, &error_fatal);
break;
case QEMU_OPTION_fwcfg:
- opts = qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"),
- optarg, true);
- if (opts == NULL) {
+ if (!qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"),
+ optarg, true)) {
exit(1);
}
break;
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-04-29 6:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 6:20 [PATCH 0/3] Minor cleanups: eliminate redundant code in QOM, block-backend and vl.c Bin Guo
2026-04-29 6:20 ` [PATCH 1/3] qom/object: merge double hash table traversal in object_property_del_child Bin Guo
2026-04-29 21:07 ` Richard Henderson
2026-04-30 9:24 ` Daniel P. Berrangé
2026-04-30 13:36 ` Philippe Mathieu-Daudé
2026-04-29 6:20 ` [PATCH 2/3] block/block-backend: delegate blk_co_preadv to blk_co_preadv_part Bin Guo
2026-04-29 21:07 ` Richard Henderson
2026-05-12 12:58 ` Kevin Wolf
2026-04-29 6:20 ` Bin Guo [this message]
2026-04-29 8:04 ` [PATCH 3/3] system/vl.c: inline qemu_opts_parse_noisily() result checks Philippe Mathieu-Daudé
2026-04-29 21:03 ` Richard Henderson
2026-04-30 6:07 ` Philippe Mathieu-Daudé
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=20260429062004.36582-4-guobin@linux.alibaba.com \
--to=guobin@linux.alibaba.com \
--cc=berrange@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--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