On Tue, Nov 9, 2021 at 6:08 AM Stefan Weil <s...@weilnetz.de> wrote: > > 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.
Why don't we just initalise retval? Alistair > > Fixes: b863f0b75852 ("device_tree: Add qemu_fdt_add_path") > Signed-off-by: Stefan Weil <s...@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; > } > -- > 2.30.2 > >