[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[committed] Fix Wformat warnings with make CC="gcc -m32"



Hi,

We see this warning (and similar) with make CC="gcc -m32":
...
dwz.c: In function ‘calculate_section_distance’:
dwz.c:10517:47: warning: format ‘%lx’ expects argument of \
  type ‘long unsigned int’, but argument 4 has \
  type ‘GElf_Off {aka long long unsigned int}’ [-Wformat=]
      error (0, 0, "Section header table: [0x%lx, 0x%ld)", prev_offset,
...

Fix this by using %llx and casting the argument to unsigned long long.

Committed to trunk.

Thanks,
- Tom

Fix Wformat warnings with make CC="gcc -m32"

2019-07-04  Tom de Vries  <tdevries@suse.de>

	PR dwz/24765
	* dwz.c (calculate_section_distance): Fix Wformat warnings.

---
 dwz.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/dwz.c b/dwz.c
index 19e8f10..f854c66 100644
--- a/dwz.c
+++ b/dwz.c
@@ -10514,15 +10514,18 @@ calculate_section_distance (DSO *dso, unsigned int *sorted_section_numbers,
 	{
 	  error (0, 0, "Section overlap detected");
 	  if (prev == dso->ehdr.e_shnum)
-	    error (0, 0, "Section header table: [0x%lx, 0x%ld)", prev_offset,
-		   prev_offset + prev_size);
+	    error (0, 0, "Section header table: [0x%llx, 0x%lld)",
+		   (unsigned long long)prev_offset,
+		   (unsigned long long)(prev_offset + prev_size));
 	  else
-	    error (0, 0, "Section %d: [0x%lx, 0x%ld)", j, prev_offset,
-		   prev_offset + prev_size);
+	    error (0, 0, "Section %d: [0x%llx, 0x%lld)", j,
+		   (unsigned long long)prev_offset,
+		   (unsigned long long)(prev_offset + prev_size));
 	  if (j == dso->ehdr.e_shnum)
-	    error (0, 0, "Section header table: 0x%lx", offset);
+	    error (0, 0, "Section header table: 0x%llx",
+		   (unsigned long long)offset);
 	  else
-	    error (0, 0, "Section %d: 0x%lx", j, offset);
+	    error (0, 0, "Section %d: 0x%llx", j, (unsigned long long)offset);
 	  return 1;
 	}