All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Gonglei \(Arei\)" <arei.gonglei@huawei.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	"Huangpeng \(Peter\)" <peter.huangpeng@huawei.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] hw/arm/boot: fix uninitialized scalar variable warning reported by coverity
Date: Mon, 24 Nov 2014 18:32:53 +0800	[thread overview]
Message-ID: <54730955.3040103@huawei.com> (raw)
In-Reply-To: <CAFEAcA_epH7Hcqd3uhzs-tjtTi8Y1gC3UUk5hZHsRaTAUje5dg@mail.gmail.com>

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.



WARNING: multiple messages have this Message-ID (diff)
From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	"Huangpeng (Peter)" <peter.huangpeng@huawei.com>
Subject: Re: [Qemu-devel] [PATCH] hw/arm/boot: fix uninitialized scalar variable warning reported by coverity
Date: Mon, 24 Nov 2014 18:32:53 +0800	[thread overview]
Message-ID: <54730955.3040103@huawei.com> (raw)
In-Reply-To: <CAFEAcA_epH7Hcqd3uhzs-tjtTi8Y1gC3UUk5hZHsRaTAUje5dg@mail.gmail.com>

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.

  reply	other threads:[~2014-11-24 10:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-24  3:30 [Qemu-trivial] [PATCH] hw/arm/boot: fix uninitialized scalar variable warning reported by coverity zhanghailiang
2014-11-24  3:30 ` [Qemu-devel] " zhanghailiang
2014-11-24 10:03 ` [Qemu-trivial] " Peter Maydell
2014-11-24 10:03   ` Peter Maydell
2014-11-24 10:32   ` zhanghailiang [this message]
2014-11-24 10:32     ` zhanghailiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54730955.3040103@huawei.com \
    --to=zhang.zhanghailiang@huawei.com \
    --cc=arei.gonglei@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.