[rpcd PATCH] iwinfo: fix compilation error with GCC 12

Ansuel Smith ansuelsmth at gmail.com
Thu May 19 05:48:39 PDT 2022

From: Christian 'Ansuel' Marangi <ansuelsmth at gmail.com>

Fix compilation error with GCC 12.

In file included from /home/ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/libubus.h:23,
                 from iwinfo.c:21:
In function 'blobmsg_close_array',
    inlined from 'rpc_iwinfo_assoclist' at iwinfo.c:643:3:
/home/ansuel/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/libubox/blobmsg.h:250:9: error: 'c' may be used uninitialized [-Werror=maybe-uninitialized]
  250 |         blob_nest_end(buf, cookie);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
iwinfo.c: In function 'rpc_iwinfo_assoclist':
iwinfo.c:564:15: note: 'c' was declared here
  564 |         void *c, *d, *e;
      |               ^
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.

Signed-off-by: Christian 'Ansuel' Marangi <ansuelsmth at gmail.com>
 iwinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/iwinfo.c b/iwinfo.c
index 6c0319e..38484c8 100644
--- a/iwinfo.c
+++ b/iwinfo.c
@@ -561,7 +561,7 @@ rpc_iwinfo_assoclist(struct ubus_context *ctx, struct ubus_object *obj,
 	char res[IWINFO_BUFSIZE];
 	struct iwinfo_assoclist_entry *a;
 	struct ether_addr *macaddr = NULL;
-	void *c, *d, *e;
+	void *c = NULL, *d, *e;
 	struct blob_attr *tb[__RPC_A_MAX];
 	bool found = false;

More information about the openwrt-devel mailing list