diff mbox

[v2] hw/arm/boot: fix uninitialized scalar variable warning reported by coverity

Message ID 1416826240-12368-1-git-send-email-zhang.zhanghailiang@huawei.com
State New
Headers show

Commit Message

Zhanghailiang Nov. 24, 2014, 10:50 a.m. UTC
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>
---
v2:
- add a note to the doc comment for load_dtb (Peter Maydell)
  Thanks for comment.
---
 hw/arm/boot.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Peter Maydell Nov. 25, 2014, 2:48 p.m. UTC | #1
On 24 November 2014 at 10:50, 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>
> ---
> v2:
> - add a note to the doc comment for load_dtb (Peter Maydell)
>   Thanks for comment.



Applied to target-arm.next, thanks.

-- PMM
diff mbox

Patch

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 0014c34..e6a3c5b 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -329,6 +329,8 @@  static void set_kernel_args_old(const struct arm_boot_info *info)
  * Returns: the size of the device tree image on success,
  *          0 if the image size exceeds the limit,
  *          -1 on errors.
+ *
+ * Note: Must not be called unless have_dtb(binfo) is true.
  */
 static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
                     hwaddr addr_limit)
@@ -352,7 +354,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");