[PATCH kvmtool 1/2] option parsing: fix type of empty .argh parameter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 arm/include/arm-common/kvm-config-arch.h | 2 +-
 builtin-run.c                            | 2 +-
 include/kvm/parse-options.h              | 7 ++++---
 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 87f50352e..23a74867a 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 941ae0e4b..bd0d0b9c2 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 b03f15124..c2e083205 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,	    \
-- 
2.25.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux