From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound.soverin.net (outbound.soverin.net [IPv6:2a01:4f8:fff0:2d:8::215]) by sourceware.org (Postfix) with ESMTPS id 292FD3858401 for ; Wed, 6 Oct 2021 21:55:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 292FD3858401 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from smtp.soverin.net (unknown [10.10.3.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id E6D4B60816; Wed, 6 Oct 2021 21:55:12 +0000 (UTC) Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.142]) by soverin.net Received: by reform (Postfix, from userid 1000) id 19F9F2E817D9; Wed, 6 Oct 2021 23:55:10 +0200 (CEST) Date: Wed, 6 Oct 2021 23:55:10 +0200 From: Mark Wielaard To: Jan-Benedict Glaw Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH] Tests: Fix warning in show-die-info.c Message-ID: References: <20211005153640.brpi3yyvmjxtovbh@lug-owl.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="hTBRRJk9p8HPWsdP" Content-Disposition: inline In-Reply-To: <20211005153640.brpi3yyvmjxtovbh@lug-owl.de> X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Oct 2021 21:55:15 -0000 --hTBRRJk9p8HPWsdP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 ?: "". Which is what I pushed (see attached). Thanks, Mark --hTBRRJk9p8HPWsdP Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-tests-Handle-dwarf_attr_string-returning-NULL-in-sho.patch" >From 47b0ebe9033daa7ac9c732b25c85520b97f9635a Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 6 Oct 2021 23:53:34 +0200 Subject: [PATCH] tests: Handle dwarf_attr_string returning NULL in show-die-info.c Reported-by: Jan-Benedict Glaw Signed-off-by: Mark Wielaard --- tests/ChangeLog | 4 ++++ tests/show-die-info.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index d289b27c..07e018b0 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2021-10-06 Mark Wielaard + + * show-die-info.c (handle): Handle dwarf_attr_string returning NULL. + 2021-10-06 Di Chen PR28242 diff --git a/tests/show-die-info.c b/tests/show-die-info.c index 34e27a3b..1a3191cd 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) ?: ""); puts (""); if (dwarf_hasattr (die, DW_AT_low_pc) && dwarf_lowpc (die, &addr) == 0) -- 2.32.0 --hTBRRJk9p8HPWsdP--