hw/virtio: Fix brace Werror with clang 6.0.0
PATCH 1/2 hw/virtio: Fix brace Werror with clang 6.0.0
The warning is
hw/virtio/vhost-user.c:1319:26: error: suggest braces
around initialization of subobject [-Werror,-Wmissing-braces]
VhostUserMsg msg = { 0 };
^
{}While the original code is correct, and technically exactly correct as per ISO C89, both GCC and Clang support plain empty set of braces as an extension.
--- hw/virtio/vhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/vhost-user.c +1 -1
@@ -1316,7 +1316,7 @@ static bool vhost_user_requires_shm_log(struct vhost_dev *dev)static int vhost_user_migration_done (struct vhost_dev *dev,char * mac_addr) { -VhostUserMsg msg = {0 }; +VhostUserMsg msg = { };assert (dev->vhost_ops->backend_type ==VHOST_BACKEND_TYPE_USER );
Signature · 1 line
2.17.0
PATCH 2/2 target/s390x: Fix brace Werror with clang 6.0.0
The warning is
target/s390x/misc_helper.c:209:21: error: suggest
braces around initialization of subobject [-Werror,-Wmissing-braces]
SysIB sysib = { 0 };
^
{}While the original code is correct, and technically exactly correct as per ISO C89, both GCC and Clang support plain empty set of braces as an extension.
--- target/s390x/misc_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/misc_helper.c +1 -1
@@ -206,7 +206,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, uint64_t r0, uint64_t r1)const MachineState *ms =MACHINE (qdev_get_machine ());uint16_t total_cpus =0 , conf_cpus =0 , reserved_cpus =0 ;S390CPU *cpu =s390_env_get_cpu (env); -SysIB sysib = {0 }; +SysIB sysib = { };int i, cc =0 ;if ((r0 &STSI_R0_FC_MASK ) >STSI_R0_FC_LEVEL_3 ) {
Signature · 1 line
2.17.0
Re: [Qemu-devel] [PATCH 2/2] target/s390x: Fix brace Werror with clang 6.0.0
Quoted 8 lines · Richard Henderson
The warning is
target/s390x/misc_helper.c:209:21: error: suggestbraces around initialization of subobject [-Werror,-Wmissing-braces] SysIB sysib = { 0 }; ^ {}
Quoted 8 lines
While the original code is correct, and technically exactly correct as per ISO C89, both GCC and Clang support plain empty set of braces as an extension.
Cc Alexander Graf <[email protected]>Cc David Hildenbrand <[email protected]>Cc Cornelia Huck <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Quoted 18 lines
--- target/s390x/misc_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/s390x/misc_helper.c +1
-1@@ -206,7 +206,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, uint64_t r0, uint64_t r1)const MachineState *ms =MACHINE (qdev_get_machine ());uint16_t total_cpus =0 , conf_cpus =0 , reserved_cpus =0 ;S390CPU *cpu =s390_env_get_cpu (env); -SysIB sysib = {0 }; +SysIB sysib = { };int i, cc =0 ;if ((r0 &STSI_R0_FC_MASK ) >STSI_R0_FC_LEVEL_3 ) {
Quoted 8 lines · Richard Henderson
The warning is
hw/virtio/vhost-user.c:1319:26: error: suggest bracesaround initialization of subobject [-Werror,-Wmissing-braces] VhostUserMsg msg = { 0 }; ^ {}
Quoted 6 lines
While the original code is correct, and technically exactly correct as per ISO C89, both GCC and Clang support plain empty set of braces as an extension.
Cc Michael S. Tsirkin <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Quoted 18 lines
--- hw/virtio/vhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/vhost-user.c +1
-1@@ -1316,7 +1316,7 @@ static bool vhost_user_requires_shm_log(struct vhost_dev *dev)static int vhost_user_migration_done (struct vhost_dev *dev,char * mac_addr) { -VhostUserMsg msg = {0 }; +VhostUserMsg msg = { };assert (dev->vhost_ops->backend_type ==VHOST_BACKEND_TYPE_USER );
Quoted 10 lines · Richard Henderson
The warning is
hw/virtio/vhost-user.c:1319:26: error: suggest bracesaround initialization of subobject [-Werror,-Wmissing-braces] VhostUserMsg msg = { 0 }; ^ {}While the original code is correct, and technically exactly correct as per ISO C89, both GCC and Clang support plain empty set of braces
s/C89/C99/ (the guarantee of a universal {0} initializer was only added in C99, if I recall correctly)
Quoted 8 lines
as an extension.
Cc Michael S. Tsirkin <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- hw/virtio/vhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
It's annoying that we have to work around clang's bogus warning by resorting to an extension. But such is life.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org