diff mbox series

Tests: Fix warning in show-die-info.c

Message ID 20211005153640.brpi3yyvmjxtovbh@lug-owl.de
State Committed
Headers show
Series Tests: Fix warning in show-die-info.c | expand

Commit Message

Jan-Benedict Glaw Oct. 5, 2021, 3:36 p.m. UTC
Hi!

My last email had a wrong subject, though the patch was correct.
Here's a second patch, this time *actally* for tests/show-die-info.c:





Please keep me Cc'ed as I'm not subscribed!

Thanks,
  Jan-Benedict
--

Comments

Mark Wielaard Oct. 6, 2021, 9:55 p.m. UTC | #1
Hi Jan-Benedict,

On Tue, Oct 05, 2021 at 05:36:40PM +0200, Jan-Benedict Glaw wrote:
> 
> My last email had a wrong subject, though the patch was correct.
> Here's a second patch, this time *actally* for tests/show-die-info.c:
> 
> diff --git a/tests/show-die-info.c b/tests/show-die-info.c
> index 34e27a3b..0823cc60 100644
> --- a/tests/show-die-info.c
> +++ b/tests/show-die-info.c
> @@ -97,7 +97,7 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
>    printf ("%*s Attrs     :", n * 5, "");
>    for (cnt = 0; cnt < 0xffff; ++cnt)
>      if (dwarf_hasattr (die, cnt))
> -      printf (" %s", dwarf_attr_string (cnt));
> +      printf (" %s", (dwarf_attr_string (cnt)? dwarf_attr_string (cnt): ""));
>    puts ("");
>  
>    if (dwarf_hasattr (die, DW_AT_low_pc) && dwarf_lowpc (die, &addr) == 0)

This can be fixed in a shorter way using dwarf_attr_string ?: "<unknown>".
Which is what I pushed (see attached).

Thanks,

Mark
diff mbox series

Patch

diff --git a/tests/show-die-info.c b/tests/show-die-info.c
index 34e27a3b..0823cc60 100644
--- a/tests/show-die-info.c
+++ b/tests/show-die-info.c
@@ -97,7 +97,7 @@  handle (Dwarf *dbg, Dwarf_Die *die, int n)
   printf ("%*s Attrs     :", n * 5, "");
   for (cnt = 0; cnt < 0xffff; ++cnt)
     if (dwarf_hasattr (die, cnt))
-      printf (" %s", dwarf_attr_string (cnt));
+      printf (" %s", (dwarf_attr_string (cnt)? dwarf_attr_string (cnt): ""));
   puts ("");
 
   if (dwarf_hasattr (die, DW_AT_low_pc) && dwarf_lowpc (die, &addr) == 0)