Skip to contentSkip to conversation

qemu-pr-helper: Do not use {0} for initialization

PATCH In review Paolo Bonzini 2 participants 2 messages Oct 20, 2017 – Oct 23, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-pr-helper: Do not use {0} for initialization

The first field in struct dm_ioctl is an array, and old GCC warns about it with -Wmissing-braces (GCC <= 4.8). The "{0}" universal zero initializer is only useful if the other side might be a scalar; for a struct, "{}" is enough and shuts up the compiler.

---
 scsi/qemu-pr-helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scsi/qemu-pr-helper.c +1 -1
index dd9785143b..8e475f676e 100644
@@ -258,12 +258,12 @@ static void *dm_dev_ioctl(int fd, int ioc, struct dm_ioctl *dm)
 
 static void dm_init(void)
 {
+    struct dm_ioctl dm = {};
     control_fd = open(CONTROL_PATH, O_RDWR);
     if (control_fd < 0) {
         perror("Cannot open " CONTROL_PATH);
         exit(1);
     }
-    struct dm_ioctl dm = { 0 };
     if (!dm_ioctl(DM_VERSION, &dm)) {
         perror("ioctl");
         exit(1);
Signature · 1 line
2.14.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Paolo Bonzini

The first field in struct dm_ioctl is an array, and old GCC warns about it with -Wmissing-braces (GCC <= 4.8). The "{0}" universal zero initializer is only useful if the other side might be a scalar; for a struct, "{}" is enough and shuts up the compiler.

---
 scsi/qemu-pr-helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)