[2/4] libctf: work around an uninitialized variable warning

Message ID 20230324133625.450723-2-nick.alcock@oracle.com
State Repeat Merge
Headers
Series [1/4] libctf: fix assertion failure with no system qsort_r |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Nick Alcock March 24, 2023, 1:36 p.m. UTC
  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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/libctf/ctf-lookup.c b/libctf/ctf-lookup.c
index 10ababf1489..950c0a809ac 100644
--- a/libctf/ctf-lookup.c
+++ b/libctf/ctf-lookup.c
@@ -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;