Message ID | 20180512014801.17566-1-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | [1/2] hw/virtio: Fix brace Werror with clang 6.0.0 | expand |
On 05/11/2018 10:48 PM, Richard Henderson wrote: > 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. > > Cc: Michael S. Tsirkin <mst@redhat.com> > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > hw/virtio/vhost-user.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c > index 38da8692bb..b455fca394 100644 > --- a/hw/virtio/vhost-user.c > +++ b/hw/virtio/vhost-user.c > @@ -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); > >
On 05/11/2018 08:48 PM, Richard Henderson wrote: > 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 s/C89/C99/ (the guarantee of a universal {0} initializer was only added in C99, if I recall correctly) > as an extension. > > Cc: Michael S. Tsirkin <mst@redhat.com> > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > 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. Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 38da8692bb..b455fca394 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -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);
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. Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- hw/virtio/vhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.0