This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[COMMITTED] tests: Don't printf a known NULL symname in backtrace-dwarf.c.


GCC9 on 32bit systems might warn about '%s' directive argument is null
for symname in backtrace-dwarf.c. Just check whether symname is NULL.

This is an identical fix for the same issue as found in backtrace.c,
but now in backtrace-dwarf.c

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 tests/ChangeLog         | 5 +++++
 tests/backtrace-dwarf.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index a4f5dd3..d6dafa4 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,10 @@
 2019-04-30  Mark Wielaard  <mark@klomp.org>
 
+	* backtrace-dwarf.c (frame_callback): Explicitly check symname is
+	NULL.
+
+2019-04-30  Mark Wielaard  <mark@klomp.org>
+
 	* backtrace.c (frame_callback): Explicitly check symname is NULL.
 
 2019-03-04  Mark Wielaard  <mark@klomp.org>
diff --git a/tests/backtrace-dwarf.c b/tests/backtrace-dwarf.c
index dfbf185..f446bc3 100644
--- a/tests/backtrace-dwarf.c
+++ b/tests/backtrace-dwarf.c
@@ -101,7 +101,7 @@ frame_callback (Dwfl_Frame *state, void *frame_arg)
   if (mod)
     symname = dwfl_module_addrname (mod, pc_adjusted);
 
-  printf ("%#" PRIx64 "\t%s\n", (uint64_t) pc, symname);
+  printf ("%#" PRIx64 "\t%s\n", (uint64_t) pc, symname ?: "<null>");
 
   if (symname && (strcmp (symname, "main") == 0
 		  || strcmp (symname, ".main") == 0))
-- 
1.8.3.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]