Skip to contentSkip to conversation

block/gluster.c: Handle qdict_array_entries() failure

PATCH In review Peter Maydell 4 participants 4 messages Jun 5, 2017 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block/gluster.c: Handle qdict_array_entries() failure

In qemu_gluster_parse_json(), the call to qdict_array_entries() could return a negative error code, which we were ignoring because we assigned the result to an unsigned variable. Fix this by using the 'int' type instead, which matches the return type of qdict_array_entries() and also the type we use for the loop enumeration variable 'i'.

(Spotted by Coverity, CID 1360960.)

---
 block/gluster.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/gluster.c +1 -2
index 031596a..addceed 100644
@@ -493,8 +493,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
     Error *local_err = NULL;
     char *str = NULL;
     const char *ptr;
-    size_t num_servers;
-    int i, type;
+    int i, type, num_servers;
 
     /* create opts info from runtime_json_opts list */
     opts = qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort);
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Peter Maydell

In qemu_gluster_parse_json(), the call to qdict_array_entries() could return a negative error code, which we were ignoring because we assigned the result to an unsigned variable. Fix this by using the 'int' type instead, which matches the return type of qdict_array_entries() and also the type we use for the loop enumeration variable 'i'.

Quoted 6 lines

(Spotted by Coverity, CID 1360960.)

---
 block/gluster.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v1 1/1
#2 lore raw
In reply to Peter Maydell
Quoted 10 lines · Peter Maydell

In qemu_gluster_parse_json(), the call to qdict_array_entries() could return a negative error code, which we were ignoring because we assigned the result to an unsigned variable. Fix this by using the 'int' type instead, which matches the return type of qdict_array_entries() and also the type we use for the loop enumeration variable 'i'.

(Spotted by Coverity, CID 1360960.)

Quoted 19 lines
---
 block/gluster.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/gluster.c +1 -2
index 031596a..addceed 100644
@@ -493,8 +493,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
     Error *local_err = NULL;
     char *str = NULL;
     const char *ptr;
-    size_t num_servers;
-    int i, type;
+    int i, type, num_servers;
 
     /* create opts info from runtime_json_opts list */
     opts = qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort);
Reviewed-by on v1 1/1
#3 lore raw
In reply to Peter Maydell
Quoted 31 lines · Peter Maydell

In qemu_gluster_parse_json(), the call to qdict_array_entries() could return a negative error code, which we were ignoring because we assigned the result to an unsigned variable. Fix this by using the 'int' type instead, which matches the return type of qdict_array_entries() and also the type we use for the loop enumeration variable 'i'.

(Spotted by Coverity, CID 1360960.)

---
 block/gluster.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/gluster.c +1 -2
index 031596a..addceed 100644
@@ -493,8 +493,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
     Error *local_err = NULL;
     char *str = NULL;
     const char *ptr;
-    size_t num_servers;
-    int i, type;
+    int i, type, num_servers;
 
     /* create opts info from runtime_json_opts list */
     opts = qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort);
Signature · 1 line
2.7.4

Thanks,

Also - applied to my block branch:

git://github.com/codyprime/qemu-kvm-jtc block

-Jeff