libctf: work around an uninitialized variable warning
authorNick Alcock <nick.alcock@oracle.com>
Mon, 13 Mar 2023 17:32:53 +0000 (17:32 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 24 Mar 2023 13:37:32 +0000 (13:37 +0000)
GCC 11+ complains that sym is uninitialized in ctf_symbol_next.  It
isn't, but it's not quite smart enough to figure that out (it requires
domain-specific knowledge of the state of the ctf_next_t iterator
over multiple calls).

libctf/
* ctf-lookup.c (ctf_symbol_next): Initialize sym to a suitable
value for returning if never reset during the function.

libctf/ctf-lookup.c

index 10ababf14891a35562a1a16b7a62648c7ae07b3e..950c0a809acacee430e187ea39ee2001992072b8 100644 (file)
@@ -651,7 +651,7 @@ ctf_id_t
 ctf_symbol_next (ctf_dict_t *fp, ctf_next_t **it, const char **name,
                 int functions)
 {
-  ctf_id_t sym;
+  ctf_id_t sym = CTF_ERR;
   ctf_next_t *i = *it;
   int err;