qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/arm/boot: fix uninitialized scalar variable warning reported by coverity
@ 2014-11-24  3:30 zhanghailiang
  2014-11-24 10:03 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: zhanghailiang @ 2014-11-24  3:30 UTC (permalink / raw)
  To: qemu-trivial
  Cc: pbonzini, zhanghailiang, arei.gonglei, qemu-devel,
	peter.huangpeng

Coverity reports the 'size' may be used uninitialized, but that can't happen,
because the caller has checked "if (binfo->dtb_filename || binfo->get_dtb)"
before call 'load_dtb'.

Here we simply remove the 'if (binfo->get_dtb)' to satisfy coverity.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
 hw/arm/boot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 0014c34..4f515b5 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -352,7 +352,7 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
             goto fail;
         }
         g_free(filename);
-    } else if (binfo->get_dtb) {
+    } else {
         fdt = binfo->get_dtb(binfo, &size);
         if (!fdt) {
             fprintf(stderr, "Board was unable to create a dtb blob\n");
-- 
1.7.12.4

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

* Re: [Qemu-devel] [PATCH] hw/arm/boot: fix uninitialized scalar variable warning reported by coverity
  2014-11-24  3:30 [Qemu-devel] [PATCH] hw/arm/boot: fix uninitialized scalar variable warning reported by coverity zhanghailiang
@ 2014-11-24 10:03 ` Peter Maydell
  2014-11-24 10:32   ` zhanghailiang
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2014-11-24 10:03 UTC (permalink / raw)
  To: zhanghailiang
  Cc: QEMU Trivial, Paolo Bonzini, Gonglei (Arei), QEMU Developers,
	Huangpeng (Peter)

On 24 November 2014 at 03:30, zhanghailiang
<zhang.zhanghailiang@huawei.com> wrote:
> Coverity reports the 'size' may be used uninitialized, but that can't happen,
> because the caller has checked "if (binfo->dtb_filename || binfo->get_dtb)"
> before call 'load_dtb'.
>
> Here we simply remove the 'if (binfo->get_dtb)' to satisfy coverity.
>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
>  hw/arm/boot.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index 0014c34..4f515b5 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -352,7 +352,7 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
>              goto fail;
>          }
>          g_free(filename);
> -    } else if (binfo->get_dtb) {
> +    } else {
>          fdt = binfo->get_dtb(binfo, &size);
>          if (!fdt) {
>              fprintf(stderr, "Board was unable to create a dtb blob\n");

If we do this I would prefer it if we add a clarifying note to the
doc comment for load_dtb:
 Must not be called unless have_dtb(binfo) is true.

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH] hw/arm/boot: fix uninitialized scalar variable warning reported by coverity
  2014-11-24 10:03 ` Peter Maydell
@ 2014-11-24 10:32   ` zhanghailiang
  0 siblings, 0 replies; 3+ messages in thread
From: zhanghailiang @ 2014-11-24 10:32 UTC (permalink / raw)
  To: Peter Maydell
  Cc: QEMU Trivial, Paolo Bonzini, Gonglei (Arei), QEMU Developers,
	Huangpeng (Peter)

On 2014/11/24 18:03, Peter Maydell wrote:
> On 24 November 2014 at 03:30, zhanghailiang
> <zhang.zhanghailiang@huawei.com> wrote:
>> Coverity reports the 'size' may be used uninitialized, but that can't happen,
>> because the caller has checked "if (binfo->dtb_filename || binfo->get_dtb)"
>> before call 'load_dtb'.
>>
>> Here we simply remove the 'if (binfo->get_dtb)' to satisfy coverity.
>>
>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>> ---
>>   hw/arm/boot.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
>> index 0014c34..4f515b5 100644
>> --- a/hw/arm/boot.c
>> +++ b/hw/arm/boot.c
>> @@ -352,7 +352,7 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
>>               goto fail;
>>           }
>>           g_free(filename);
>> -    } else if (binfo->get_dtb) {
>> +    } else {
>>           fdt = binfo->get_dtb(binfo, &size);
>>           if (!fdt) {
>>               fprintf(stderr, "Board was unable to create a dtb blob\n");
>
> If we do this I would prefer it if we add a clarifying note to the
> doc comment for load_dtb:
>   Must not be called unless have_dtb(binfo) is true.

Good idea! Will add this in v2, Thanks.

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

end of thread, other threads:[~2014-11-24 10:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-24  3:30 [Qemu-devel] [PATCH] hw/arm/boot: fix uninitialized scalar variable warning reported by coverity zhanghailiang
2014-11-24 10:03 ` Peter Maydell
2014-11-24 10:32   ` zhanghailiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).