aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2023-05-25 15:48:26 +0100
committerWill Deacon <will@kernel.org>2023-06-05 13:22:26 +0100
commitc1eecc61558d062b5195641dc977e098c08efe2e (patch)
tree0ca16a66af780e839f23781091edd7543fed5fcb
parentbc23b9d9b152eaf56bacb1e2bae9a2b2252ade46 (diff)
downloadkvmtool-c1eecc61558d062b5195641dc977e098c08efe2e.tar.gz
option parsing: fix type of empty .argh parameter
The "force-pci" and "virtio-legacy" option definitions were using '\0' to initialise an unused ".argh" member, even though this is a string. This triggers warnings with some compilers like clang. Also, for some odd reason, the .argh member was not named explicitly in the option helper macros initialisation, which made this problem harder to locate. Sanitise the option macros by always using designated initialisers for each member, and use the correct empty string for the "force-pci" and "virtio-legacy" options. This fixes warnings (promoted to errors) when compiling with clang. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Link: https://lore.kernel.org/r/20230525144827.679651-2-andre.przywara@arm.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--arm/include/arm-common/kvm-config-arch.h2
-rw-r--r--builtin-run.c2
-rw-r--r--include/kvm/parse-options.h7
3 files changed, 6 insertions, 5 deletions
diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h
index 87f50352..23a74867 100644
--- a/arm/include/arm-common/kvm-config-arch.h
+++ b/arm/include/arm-common/kvm-config-arch.h
@@ -27,7 +27,7 @@ int irqchip_parser(const struct option *opt, const char *arg, int unset);
"Specify Generic Timer frequency in guest DT to " \
"work around buggy secure firmware *Firmware should be " \
"updated to program CNTFRQ correctly*"), \
- OPT_CALLBACK_NOOPT('\0', "force-pci", NULL, '\0', \
+ OPT_CALLBACK_NOOPT('\0', "force-pci", NULL, "", \
"Force virtio devices to use PCI as their default " \
"transport (Deprecated: Use --virtio-transport " \
"option instead)", virtio_transport_parser, kvm), \
diff --git a/builtin-run.c b/builtin-run.c
index 941ae0e4..bd0d0b9c 100644
--- a/builtin-run.c
+++ b/builtin-run.c
@@ -207,7 +207,7 @@ static int mem_parser(const struct option *opt, const char *arg, int unset)
OPT_STRING('\0', "hugetlbfs", &(cfg)->hugetlbfs_path, "path", \
"Hugetlbfs path"), \
OPT_CALLBACK_NOOPT('\0', "virtio-legacy", \
- &(cfg)->virtio_transport, '\0', \
+ &(cfg)->virtio_transport, "", \
"Use legacy virtio transport (Deprecated:" \
" Use --virtio-transport option instead)", \
virtio_transport_parser, NULL), \
diff --git a/include/kvm/parse-options.h b/include/kvm/parse-options.h
index b03f1512..c2e08320 100644
--- a/include/kvm/parse-options.h
+++ b/include/kvm/parse-options.h
@@ -132,7 +132,8 @@ struct option {
.type = OPTION_STRING, \
.short_name = (s), \
.long_name = (l), \
- .value = check_vtype(v, const char **), (a), \
+ .value = check_vtype(v, const char **), \
+ .argh = (a), \
.help = (h) \
}
@@ -166,7 +167,7 @@ struct option {
.short_name = (s), \
.long_name = (l), \
.value = (v), \
- (a), \
+ .argh = (a), \
.help = (h), \
.callback = (f), \
.ptr = (p), \
@@ -178,7 +179,7 @@ struct option {
.short_name = (s), \
.long_name = (l), \
.value = (v), \
- (a), \
+ .argh = (a), \
.help = (h), \
.callback = (f), \
.flags = PARSE_OPT_NOARG, \