qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] device_tree: Fix compiler error


From: Laurent Vivier
Subject: Re: [PATCH] device_tree: Fix compiler error
Date: Fri, 17 Dec 2021 11:11:15 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0

Le 08/11/2021 à 21:07, Stefan Weil a écrit :
A build with gcc (Debian 10.2.1-6) 10.2.1 20210110 fails:

../../../softmmu/device_tree.c: In function ‘qemu_fdt_add_path’:
../../../softmmu/device_tree.c:560:18: error: ‘retval’ may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
   560 |     int namelen, retval;
       |                  ^~~~~~

This is not a real error, but the compiler can be satisfied with a small change.

Fixes: b863f0b75852 ("device_tree: Add qemu_fdt_add_path")
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
  softmmu/device_tree.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c
index 3965c834ca..9e96f5ecd5 100644
--- a/softmmu/device_tree.c
+++ b/softmmu/device_tree.c
@@ -564,7 +564,7 @@ int qemu_fdt_add_path(void *fdt, const char *path)
          return -1;
      }
- while (p) {
+    do {
          name = p + 1;
          p = strchr(name, '/');
          namelen = p != NULL ? p - name : strlen(name);
@@ -584,7 +584,7 @@ int qemu_fdt_add_path(void *fdt, const char *path)
          }
parent = retval;
-    }
+    } while (p);
return retval;
  }


I think to add a "g_assert_nonull(p);" before the loop would inform the compiler that we always go in the loop and remove the compiler error.

Thanks,
Laurent



reply via email to

[Prev in Thread] Current Thread [Next in Thread]