All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block/gluster.c: Handle qdict_array_entries() failure
@ 2017-06-05 17:01 Peter Maydell
  2017-06-05 17:48 ` Eric Blake
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Peter Maydell @ 2017-06-05 17:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches, Jeff Cody, Kevin Wolf, Max Reitz, qemu-block

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.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 block/gluster.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/block/gluster.c b/block/gluster.c
index 031596a..addceed 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] block/gluster.c: Handle qdict_array_entries() failure
  2017-06-05 17:01 [Qemu-devel] [PATCH] block/gluster.c: Handle qdict_array_entries() failure Peter Maydell
@ 2017-06-05 17:48 ` Eric Blake
  2017-06-05 20:14 ` Philippe Mathieu-Daudé
  2017-06-05 20:34 ` Jeff Cody
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Blake @ 2017-06-05 17:48 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Kevin Wolf, Jeff Cody, Max Reitz, qemu-block, patches

[-- Attachment #1: Type: text/plain, Size: 775 bytes --]

On 06/05/2017 12:01 PM, Peter Maydell wrote:
> 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.)
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  block/gluster.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] block/gluster.c: Handle qdict_array_entries() failure
  2017-06-05 17:01 [Qemu-devel] [PATCH] block/gluster.c: Handle qdict_array_entries() failure Peter Maydell
  2017-06-05 17:48 ` Eric Blake
@ 2017-06-05 20:14 ` Philippe Mathieu-Daudé
  2017-06-05 20:34 ` Jeff Cody
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-06-05 20:14 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Kevin Wolf, Jeff Cody, Max Reitz, qemu-block, patches

On 06/05/2017 02:01 PM, Peter Maydell wrote:
> 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.)
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  block/gluster.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/block/gluster.c b/block/gluster.c
> index 031596a..addceed 100644
> --- a/block/gluster.c
> +++ b/block/gluster.c
> @@ -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);
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] block/gluster.c: Handle qdict_array_entries() failure
  2017-06-05 17:01 [Qemu-devel] [PATCH] block/gluster.c: Handle qdict_array_entries() failure Peter Maydell
  2017-06-05 17:48 ` Eric Blake
  2017-06-05 20:14 ` Philippe Mathieu-Daudé
@ 2017-06-05 20:34 ` Jeff Cody
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Cody @ 2017-06-05 20:34 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, patches, Kevin Wolf, Max Reitz, qemu-block

On Mon, Jun 05, 2017 at 06:01:38PM +0100, Peter Maydell wrote:
> 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.)
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  block/gluster.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/block/gluster.c b/block/gluster.c
> index 031596a..addceed 100644
> --- a/block/gluster.c
> +++ b/block/gluster.c
> @@ -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);
> -- 
> 2.7.4
> 

Thanks,

Reviewed-by: Jeff Cody <jcody@redhat.com>

Also - applied to my block branch:

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

-Jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-05 20:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05 17:01 [Qemu-devel] [PATCH] block/gluster.c: Handle qdict_array_entries() failure Peter Maydell
2017-06-05 17:48 ` Eric Blake
2017-06-05 20:14 ` Philippe Mathieu-Daudé
2017-06-05 20:34 ` Jeff Cody

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.