dwarf: Don't omit second operand of '?' operator

Message ID 20210501075516.9596-1-mforney@mforney.org
State New
Headers show
Series
  • dwarf: Don't omit second operand of '?' operator
Related show

Commit Message

Michael Forney May 1, 2021, 7:55 a.m.
This is a GNU C extension and is not valid in ISO C.

binutils/ChangeLog:
2021-05-01  Michael Forney <mforney@mforney.org>

	* dwarf.c: Don't omit second operand of '?' operator.
---
 binutils/dwarf.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

-- 
2.31.1

Comments

Luis Machado via Binutils May 3, 2021, 1:25 p.m. | #1
On Sat, May 01, 2021 at 12:55:16AM -0700, Michael Forney wrote:
> This is a GNU C extension and is not valid in ISO C.

> 

> binutils/ChangeLog:

> 2021-05-01  Michael Forney <mforney@mforney.org>

> 

> 	* dwarf.c: Don't omit second operand of '?' operator.


OK.

-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index adb5c130ccd..d93d9239684 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -3826,9 +3826,13 @@  process_debug_info (struct dwarf_section * section,
 		  offset_size == 8 ? "64-bit" : "32-bit");
 	  printf (_("   Version:       %d\n"), compunit.cu_version);
 	  if (compunit.cu_version >= 5)
-	    printf (_("   Unit Type:     %s (%x)\n"),
-		    get_DW_UT_name (compunit.cu_unit_type) ?: "???",
-		    compunit.cu_unit_type);
+	    {
+	      const char *name = get_DW_UT_name (compunit.cu_unit_type);
+
+	      printf (_("   Unit Type:     %s (%x)\n"),
+		      name ? name : "???",
+		      compunit.cu_unit_type);
+	    }
 	  printf (_("   Abbrev Offset: 0x%s\n"),
 		  dwarf_vmatoa ("x", compunit.cu_abbrev_offset));
 	  printf (_("   Pointer Size:  %d\n"), compunit.cu_pointer_size);