summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Huehn <thomas.huehn@hs-nordhausen.de>2021-09-28 01:59:39 +0200
committerPetr Štetiar <ynezz@true.cz>2022-02-19 11:39:06 +0100
commit51283f9f1df5dedcba35f40367ef5d4ab1a55e0b (patch)
tree70e88d78bbd701eee3063eef2ccd9468684e214c
parent2f8b1360df25bab375ec60bbba2dce8dd796161c (diff)
downloaduhttpd2-51283f9f1df5dedcba35f40367ef5d4ab1a55e0b.tar.gz
fix compiler uninitialized variable
In file included from ubus.c:20: ubus.c: In function 'uh_ubus_list_cb': libubox/blobmsg.h:256:9: error: 'o' may be used uninitialized in this function [-Werror=maybe-uninitialized] 256 | blob_nest_end(buf, cookie); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ ubus.c:591:19: note: 'o' was declared here 591 | void *t, *o; | ^ cc1: all warnings being treated as errors Signed-off-by: Thomas Huehn <thomas.huehn@hs-nordhausen.de> Acked-by: Alexander Couzens <lynxis@fe80.eu>
-rw-r--r--ubus.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ubus.c b/ubus.c
index 619135c..99cc400 100644
--- a/ubus.c
+++ b/ubus.c
@@ -588,7 +588,7 @@ static void uh_ubus_list_cb(struct ubus_context *ctx, struct ubus_object_data *o
struct blob_attr *sig, *attr;
struct list_data *data = priv;
int rem, rem2;
- void *t, *o;
+ void *t, *o=NULL;
if (!data->verbose) {
blobmsg_add_string(data->buf, NULL, obj->path);
@@ -598,8 +598,12 @@ static void uh_ubus_list_cb(struct ubus_context *ctx, struct ubus_object_data *o
if (!obj->signature)
return;
- if (data->add_object)
+ if (data->add_object) {
o = blobmsg_open_table(data->buf, obj->path);
+ if (!o)
+ return;
+ }
+
blob_for_each_attr(sig, obj->signature, rem) {
t = blobmsg_open_table(data->buf, blobmsg_name(sig));
rem2 = blobmsg_data_len(sig);
@@ -630,6 +634,7 @@ static void uh_ubus_list_cb(struct ubus_context *ctx, struct ubus_object_data *o
}
blobmsg_close_table(data->buf, t);
}
+
if (data->add_object)
blobmsg_close_table(data->buf, o);
}