vl: Fix compile issue with Werror option
PATCH 1/1 vl: Fix compile issue with Werror option
Currently, if compile with Werror option, the error message shows below:
GEN config-host.h
GEN trace/generated-tracers.h
CHK version_gen.h
GEN trace/generated-tracers.c
CC vl.ovl.c: In function ‘get_boot_devices_list’:
vl.c:1257:21: error: ‘bootpath’ may be used uninitialized
in this function [-Werror=maybe-uninitialized]
len = strlen(bootpath) + 1;
^cc1: all warnings being treated as errors
make: *** [vl.o] Error 1
This patch is to solve this issue.
--- vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
vl.c +1 -1
@@ -1230,7 +1230,7 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes)char *list =NULL ; QTAILQ_FOREACH(i, &fw_boot_order, link) { -char *devpath =NULL , *bootpath; +char *devpath =NULL , *bootpath =NULL ;size_t len;if (i->dev) {
Signature · 1 line
1.8.2.1
Quoted 28 lines · Mike Qiu
Currently, if compile with Werror option, the error message shows below:
GEN
config-host.h
GENtrace/generated-tracers.h
CHKversion_gen.h
GENtrace/generated-tracers.c
CC vl.ovl.c: In function ‘get_boot_devices_list’:
vl.c:1257:21: error: ‘bootpath’ may be used uninitializedin this function [-Werror=maybe-uninitialized] len = strlen(bootpath) + 1; ^cc1: all warnings being treated as errors
make: *** [vl.o] Error 1This patch is to solve this issue.
Signed-off-by Mike Qiu <[email protected]>--- vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)vl.c +0
-0
vl.c char *get_boot_devices_list(size_t *size, bool ignore_suffixes) · line 1236
Quoted 8 lines
vl.c +1
-1@@ -1230,7 +1230,7 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes)char *list =NULL ; QTAILQ_FOREACH(i, &fw_boot_order, link) { -char *devpath =NULL , *bootpath; +char *devpath =NULL , *bootpath =NULL ;size_t len;if (i->dev) {
Compiler version? I'm asking because bootpath looks quite defined on all paths leading to the line you quoted:
QTAILQ_FOREACH(i, &fw_boot_order, link) {
char *devpath = NULL, *bootpath;
size_t len;
if (i->dev) {
devpath = qdev_get_fw_dev_path(i->dev);
assert(devpath);
}
if (i->suffix && devpath) {
size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1;---> bootpath = g_malloc(bootpathlen);
snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix);
g_free(devpath);
} else if (devpath) {
---> bootpath = devpath;
} else {
assert(i->suffix);
---> bootpath = g_strdup(i->suffix);
}
if (total) {
list[total-1] = '\n';
}
len = strlen(bootpath) + 1;