[PATCH] libctf: check for problems with error returns
Nick Alcock
nick.alcock@oracle.com
Tue Jan 30 14:22:22 GMT 2024
On 30 Jan 2024, Andreas Schwab said:
> ./libtool --quiet --tag=CC --mode=link gcc -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -Wno-error -I../../libctf/../include -I../../libctf -I. -I./../bfd /home/abuild/rpmbuild/BUILD/binutils-2.42/libctf/testsuite/libctf-writable/libctf-errors.c -o tmpdir/lookup libctf.la
> /home/abuild/rpmbuild/BUILD/binutils-2.42/libctf/testsuite/libctf-writable/libctf-errors.c: In function 'main':
> /home/abuild/rpmbuild/BUILD/binutils-2.42/libctf/testsuite/libctf-writable/libctf-errors.c:54:9: warning: 'stype' may be used uninitialized in this function [-Wmaybe-uninitialized]
> while ((ret = ctf_member_next (fp, stype, &i, NULL, NULL, 0)) >= 0) {
> ^
Thanks! I was being sloppy on error paths and the compiler has spotted
my sin... will push the attached fix shortly, if your compiler is happy
(none of my compilers spot this one).
------------- >8 -----------
>From 78fd0d4e60e8aed4c7396837d64cf1d1114b8c24 Mon Sep 17 00:00:00 2001
From: Nick Alcock <nick.alcock@oracle.com>
Date: Tue, 30 Jan 2024 14:18:54 +0000
Subject: [PATCH] libctf: fix uninitialized variables in testsuite
Just because a path is an error path doesn't mean the program terminates
there if you don't ask it to. (And we don't want to -- but that means
we need to initialize the variables that are missed if an error happens to
*something*. Type ID 0 (unimplemented) will do: it'll induce further
ECTF_BADID errors, but that's no bad thing.)
---
libctf/testsuite/libctf-writable/libctf-errors.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libctf/testsuite/libctf-writable/libctf-errors.c b/libctf/testsuite/libctf-writable/libctf-errors.c
index 71f8268cfad..2790b608396 100644
--- a/libctf/testsuite/libctf-writable/libctf-errors.c
+++ b/libctf/testsuite/libctf-writable/libctf-errors.c
@@ -12,7 +12,7 @@ main (int argc, char *argv[])
ctf_dict_t *fp;
ctf_next_t *i = NULL;
size_t boom = 0;
- ctf_id_t itype, stype;
+ ctf_id_t itype = 0, stype = 0;
ctf_encoding_t encoding = {0};
ctf_membinfo_t mi;
ssize_t ret;
base-commit: b960445a45981873c5b1718824ea9d3b5749433a
--
2.43.0.272.gce700b77fd
More information about the Binutils
mailing list