61 lines
1.9 KiB
Diff
61 lines
1.9 KiB
Diff
|
|
From ecc0eb93e8856321ad940a85970f0db14ab9f146 Mon Sep 17 00:00:00 2001
|
|||
|
|
From: Thomas Huth <thuth@redhat.com>
|
|||
|
|
Date: Fri, 7 Jan 2022 14:38:44 +0100
|
|||
|
|
Subject: [PATCH 21/24] softmmu/device_tree: Silence compiler warning with
|
|||
|
|
--enable-sanitizers
|
|||
|
|
MIME-Version: 1.0
|
|||
|
|
Content-Type: text/plain; charset=UTF-8
|
|||
|
|
Content-Transfer-Encoding: 8bit
|
|||
|
|
|
|||
|
|
If I configure my build with --enable-sanitizers, my GCC (v8.5.0)
|
|||
|
|
complains:
|
|||
|
|
|
|||
|
|
.../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]
|
|||
|
|
int namelen, retval;
|
|||
|
|
^~~~~~
|
|||
|
|
|
|||
|
|
It's a false warning since the while loop is always executed at least
|
|||
|
|
once (p has to be non-NULL, otherwise the derefence in the if-statement
|
|||
|
|
earlier will crash). Thus let's switch to a do-while loop here instead
|
|||
|
|
to make the compiler happy in all cases.
|
|||
|
|
|
|||
|
|
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|||
|
|
Reviewed-by: Andrew Jones <drjones@redhat.com>
|
|||
|
|
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
|||
|
|
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
|
|||
|
|
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|
|||
|
|
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
|
|||
|
|
Message-id: 20220107133844.145039-1-thuth@redhat.com
|
|||
|
|
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
|
|||
|
|
---
|
|||
|
|
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.27.0
|
|||
|
|
|