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]

Re: [PATCH] Replace %Z with %z.


On Fri, 2015-09-04 at 10:13 -0700, Chih-Hung Hsieh wrote:
> Clang compiler gives warning to non-standard format %Z.

I actually had some trouble finding the definition of %Z. The newer
printf manpage doesn't even mention it. But older manpages actually say
under 'z': "Linux libc5 has Z with this meaning.  Don't use it." Also
http://www.gnu.org/software/libc/manual/html_node/Integer-Conversions.html does say "‘Z’ is a GNU extension predating this addition and should not be used in new code."

So, lets not use it.

gcc does warn about this with -Wformat -Wpedantic.
"warning: ISO C does not support the ‘Z’ gnu_printf length modifier"
But since we don't want -Wpedantic in general I filed a bug to see if we
can get a -Wformat-pedantic.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67479

I adjusted the description a little to explain the background and added
ChangeLog entries (mainly to help me make sure I reviewed all changes).
Pushed to master as attached.

Thanks,

Mark
From 2ec957327cdfae6cee592a52958a9c937ea4b13c Mon Sep 17 00:00:00 2001
From: Chih-Hung Hsieh <chh@google.com>
Date: Fri, 4 Sep 2015 10:13:02 -0700
Subject: [PATCH] Replace printf %Z length modifier with %z.

%Z is a GNU extension predating the ISO C99 %z modifier supported by
libc5 and no longer recommended.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 src/ChangeLog       | 25 +++++++++++++++++++++++++
 src/elflint.c       | 10 +++++-----
 src/findtextrel.c   |  2 +-
 src/ldscript.y      |  2 +-
 src/readelf.c       | 42 +++++++++++++++++++++---------------------
 src/unstrip.c       | 14 +++++++-------
 tests/ChangeLog     | 13 +++++++++++++
 tests/asm-tst1.c    | 24 ++++++++++++------------
 tests/asm-tst2.c    | 24 ++++++++++++------------
 tests/asm-tst3.c    | 12 ++++++------
 tests/asm-tst4.c    |  2 +-
 tests/asm-tst5.c    |  4 ++--
 tests/asm-tst6.c    | 12 ++++++------
 tests/asm-tst7.c    |  4 ++--
 tests/asm-tst8.c    |  4 ++--
 tests/asm-tst9.c    | 30 +++++++++++++++---------------
 tests/sectiondump.c |  4 ++--
 17 files changed, 133 insertions(+), 95 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 66f7ead..fb92807 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,28 @@
+2015-09-04  Chih-Hung Hsieh  <chh@google.com>
+
+	* elflint.c (check_group): Replace %Z length modifier with %z.
+	(check_note_data): Likewise.
+	* findtextrel.c (process_file): Likewise.
+	* readelf.c (handle_dynamic): Likewise.
+	(handle_symtab): Likewise.
+	(handle_verneed): Likewise.
+	(handle_verdef): Likewise.
+	(handle_versym): Likewise.
+	(print_hash_info): Likewise.
+	(print_decoded_aranges_section): Likewise.
+	(print_debug_aranges_section): Likewise.
+	(print_debug_line_section): Likewise.
+	(hex_dump): Likewise.
+	(dump_data_section): Likewise.
+	(print_string_section): Likewise.
+	(dump_archive_index): Likewise.
+	* unstrip.c (adjust_relocs): Likewise.
+	(collect_symbols): likewise.
+	(get_section_name): Likewise.
+	(find_alloc_sections_prelink): Likewise.
+	(copy_elided_sections): Likewise.
+	* ldscript.y (add_id_list): Add missing '%s'.
+
 2015-09-03  Mark Wielaard  <mjw@redhat.com>
 
 	* readelf.c (handle_core_item): Handle right shift >= 32 bits.
diff --git a/src/elflint.c b/src/elflint.c
index 0d5f34d..c1f0be5 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -2686,7 +2686,7 @@ section [%2d] '%s': section group with only one member\n"),
 
 	  if (val > shnum)
 	    ERROR (gettext ("\
-section [%2d] '%s': section index %Zu out of range\n"),
+section [%2d] '%s': section index %zu out of range\n"),
 		   idx, section_name (ebl, idx), cnt / elsize);
 	  else
 	    {
@@ -2708,7 +2708,7 @@ section [%2d] '%s': section group contains another group [%2d] '%s'\n"),
 
 		  if ((refshdr->sh_flags & SHF_GROUP) == 0)
 		    ERROR (gettext ("\
-section [%2d] '%s': element %Zu references section [%2d] '%s' without SHF_GROUP flag set\n"),
+section [%2d] '%s': element %zu references section [%2d] '%s' without SHF_GROUP flag set\n"),
 			   idx, section_name (ebl, idx), cnt / elsize,
 			   val, section_name (ebl, val));
 		}
@@ -4246,7 +4246,7 @@ phdr[%d]: unknown core file note type %" PRIu32 " at offset %" PRIu64 "\n"),
 	    else
 	      ERROR (gettext ("\
 section [%2d] '%s': unknown core file note type %" PRIu32
-			      " at offset %Zu\n"),
+			      " at offset %zu\n"),
 		     shndx, section_name (ebl, shndx),
 		     (uint32_t) nhdr.n_type, offset);
 	  }
@@ -4268,12 +4268,12 @@ section [%2d] '%s': unknown core file note type %" PRIu32
 	  default:
 	    if (shndx == 0)
 	      ERROR (gettext ("\
-phdr[%d]: unknown object file note type %" PRIu32 " at offset %Zu\n"),
+phdr[%d]: unknown object file note type %" PRIu32 " at offset %zu\n"),
 		     phndx, (uint32_t) nhdr.n_type, offset);
 	    else
 	      ERROR (gettext ("\
 section [%2d] '%s': unknown object file note type %" PRIu32
-			      " at offset %Zu\n"),
+			      " at offset %zu\n"),
 		     shndx, section_name (ebl, shndx),
 		     (uint32_t) nhdr.n_type, offset);
 	  }
diff --git a/src/findtextrel.c b/src/findtextrel.c
index 6f1a4b5..0ac6ede 100644
--- a/src/findtextrel.c
+++ b/src/findtextrel.c
@@ -406,7 +406,7 @@ cannot get program header index at offset %zd: %s"),
 	  if (shdr == NULL)
 	    {
 	      error (0, 0,
-		     gettext ("cannot get section header of section %Zu: %s"),
+		     gettext ("cannot get section header of section %zu: %s"),
 		     elf_ndxscn (scn), elf_errmsg (-1));
 	      result = 1;
 	      goto next;
diff --git a/src/ldscript.y b/src/ldscript.y
index ec58e21..3502ce1 100644
--- a/src/ldscript.y
+++ b/src/ldscript.y
@@ -735,7 +735,7 @@ add_id_list (const char *versionname, struct id_list *runp, _Bool local)
 	    if (defp != NULL && defp->u.s.local != local)
 	      error (EXIT_FAILURE, 0, versionname[0] == '\0'
 		     ? gettext ("\
-symbol '%s' is declared both local and global for unnamed version")
+symbol '%s' is declared both local and global for unnamed version '%s'")
 		     : gettext ("\
 symbol '%s' is declared both local and global for version '%s'"),
 		     runp->id, versionname);
diff --git a/src/readelf.c b/src/readelf.c
index aab8b5c..8e64400 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1582,7 +1582,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
 
   glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem);
   if (glink == NULL)
-    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
+    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %zu"),
 	   elf_ndxscn (scn));
 
   printf (ngettext ("\
@@ -2205,7 +2205,7 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
   GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
 				   &glink_mem);
   if (glink == NULL)
-    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
+    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %zu"),
 	   elf_ndxscn (scn));
 
   /* Now we can compute the number of entries in the section.  */
@@ -2463,7 +2463,7 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
   GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
 				   &glink_mem);
   if (glink == NULL)
-    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
+    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %zu"),
 	   elf_ndxscn (scn));
 
   printf (ngettext ("\
@@ -2539,7 +2539,7 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
   GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
 				   &glink_mem);
   if (glink == NULL)
-    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
+    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %zu"),
 	   elf_ndxscn (scn));
 
   int class = gelf_getclass (ebl->elf);
@@ -2843,7 +2843,7 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
 				   &glink_mem);
   size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_HALF, 1, EV_CURRENT);
   if (glink == NULL)
-    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
+    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %zu"),
 	   elf_ndxscn (scn));
 
   /* Print the header.  */
@@ -2917,7 +2917,7 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, size_t shstrndx,
 				   &glink_mem);
   if (glink == NULL)
     {
-      error (0, 0, gettext ("invalid sh_link value in section %Zu"),
+      error (0, 0, gettext ("invalid sh_link value in section %zu"),
 	     elf_ndxscn (scn));
       return;
     }
@@ -4605,7 +4605,7 @@ print_decoded_aranges_section (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn,
   glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem);
   if (glink == NULL)
     {
-      error (0, 0, gettext ("invalid sh_link value in section %Zu"),
+      error (0, 0, gettext ("invalid sh_link value in section %zu"),
 	     elf_ndxscn (scn));
       return;
     }
@@ -4686,7 +4686,7 @@ print_debug_aranges_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
       const unsigned char *hdrstart = readp;
       size_t start_offset = hdrstart - (const unsigned char *) data->d_buf;
 
-      printf (gettext ("\nTable at offset %Zu:\n"), start_offset);
+      printf (gettext ("\nTable at offset %zu:\n"), start_offset);
       if (readp + 4 > readendp)
 	{
 	invalid_data:
@@ -4804,7 +4804,7 @@ print_debug_aranges_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
       if (readp != nexthdr)
 	{
 	  size_t padding = nexthdr - readp;
-	  printf (gettext ("   %Zu padding bytes\n"), padding);
+	  printf (gettext ("   %zu padding bytes\n"), padding);
 	  readp = nexthdr;
 	}
     }
@@ -6383,7 +6383,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
     {
       size_t start_offset = linep - (const unsigned char *) data->d_buf;
 
-      printf (gettext ("\nTable at offset %Zu:\n"), start_offset);
+      printf (gettext ("\nTable at offset %zu:\n"), start_offset);
 
       if (unlikely (linep + 4 > lineendp))
 	goto invalid_data;
@@ -9355,7 +9355,7 @@ hex_dump (const uint8_t *data, size_t len)
   size_t pos = 0;
   while (pos < len)
     {
-      printf ("  0x%08Zx ", pos);
+      printf ("  0x%08zx ", pos);
 
       const size_t chunk = MIN (len - pos, 16);
 
@@ -9383,17 +9383,17 @@ static void
 dump_data_section (Elf_Scn *scn, const GElf_Shdr *shdr, const char *name)
 {
   if (shdr->sh_size == 0 || shdr->sh_type == SHT_NOBITS)
-    printf (gettext ("\nSection [%Zu] '%s' has no data to dump.\n"),
+    printf (gettext ("\nSection [%zu] '%s' has no data to dump.\n"),
 	    elf_ndxscn (scn), name);
   else
     {
       Elf_Data *data = elf_rawdata (scn, NULL);
       if (data == NULL)
-	error (0, 0, gettext ("cannot get data for section [%Zu] '%s': %s"),
+	error (0, 0, gettext ("cannot get data for section [%zu] '%s': %s"),
 	       elf_ndxscn (scn), name, elf_errmsg (-1));
       else
 	{
-	  printf (gettext ("\nHex dump of section [%Zu] '%s', %" PRIu64
+	  printf (gettext ("\nHex dump of section [%zu] '%s', %" PRIu64
 			   " bytes at offset %#0" PRIx64 ":\n"),
 		  elf_ndxscn (scn), name,
 		  shdr->sh_size, shdr->sh_offset);
@@ -9406,17 +9406,17 @@ static void
 print_string_section (Elf_Scn *scn, const GElf_Shdr *shdr, const char *name)
 {
   if (shdr->sh_size == 0 || shdr->sh_type == SHT_NOBITS)
-    printf (gettext ("\nSection [%Zu] '%s' has no strings to dump.\n"),
+    printf (gettext ("\nSection [%zu] '%s' has no strings to dump.\n"),
 	    elf_ndxscn (scn), name);
   else
     {
       Elf_Data *data = elf_rawdata (scn, NULL);
       if (data == NULL)
-	error (0, 0, gettext ("cannot get data for section [%Zu] '%s': %s"),
+	error (0, 0, gettext ("cannot get data for section [%zu] '%s': %s"),
 	       elf_ndxscn (scn), name, elf_errmsg (-1));
       else
 	{
-	  printf (gettext ("\nString section [%Zu] '%s' contains %" PRIu64
+	  printf (gettext ("\nString section [%zu] '%s' contains %" PRIu64
 			   " bytes at offset %#0" PRIx64 ":\n"),
 		  elf_ndxscn (scn), name,
 		  shdr->sh_size, shdr->sh_offset);
@@ -9429,11 +9429,11 @@ print_string_section (Elf_Scn *scn, const GElf_Shdr *shdr, const char *name)
 	      const size_t pos = start - (const char *) data->d_buf;
 	      if (unlikely (end == NULL))
 		{
-		  printf ("  [%6Zx]- %.*s\n",
+		  printf ("  [%6zx]- %.*s\n",
 			  pos, (int) (limit - start), start);
 		  break;
 		}
-	      printf ("  [%6Zx]  %s\n", pos, start);
+	      printf ("  [%6zx]  %s\n", pos, start);
 	      start = end + 1;
 	    } while (start < limit);
 	}
@@ -9557,7 +9557,7 @@ dump_archive_index (Elf *elf, const char *fname)
       return;
     }
 
-  printf (gettext ("\nIndex of archive '%s' has %Zu entries:\n"),
+  printf (gettext ("\nIndex of archive '%s' has %zu entries:\n"),
 	  fname, narsym);
 
   size_t as_off = 0;
@@ -9575,7 +9575,7 @@ dump_archive_index (Elf *elf, const char *fname)
 	    while (1)
 #endif
 	      error (EXIT_FAILURE, 0,
-		     gettext ("cannot extract member at offset %Zu in '%s': %s"),
+		     gettext ("cannot extract member at offset %zu in '%s': %s"),
 		     as_off, fname, elf_errmsg (-1));
 
 	  const Elf_Arhdr *h = elf_getarhdr (subelf);
diff --git a/src/unstrip.c b/src/unstrip.c
index 8833094..82bcdd8 100644
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -523,7 +523,7 @@ adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr,
 
     default:
       error (EXIT_FAILURE, 0,
-	     _("unexpected section type in [%Zu] with sh_link to symtab"),
+	     _("unexpected section type in [%zu] with sh_link to symtab"),
 	     elf_ndxscn (inscn));
     }
 }
@@ -771,7 +771,7 @@ collect_symbols (Elf *outelf, bool rel, Elf_Scn *symscn, Elf_Scn *strscn,
 
       if (sym->st_name >= strdata->d_size)
 	error (EXIT_FAILURE, 0,
-	       _("invalid string offset in symbol [%Zu]"), i);
+	       _("invalid string offset in symbol [%zu]"), i);
 
       struct symbol *s = &table[i - 1];
       s->map = &map[i - 1];
@@ -929,7 +929,7 @@ static inline const char *
 get_section_name (size_t ndx, const GElf_Shdr *shdr, const Elf_Data *shstrtab)
 {
   if (shdr->sh_name >= shstrtab->d_size)
-    error (EXIT_FAILURE, 0, _("cannot read section [%Zu] name: %s"),
+    error (EXIT_FAILURE, 0, _("cannot read section [%zu] name: %s"),
 	   ndx, elf_errmsg (-1));
   return shstrtab->d_buf + shdr->sh_name;
 }
@@ -1065,7 +1065,7 @@ find_alloc_sections_prelink (Elf *debug, Elf_Data *debug_shstrtab,
       if (!match)
 	{
 	  fail = true;
-	  error (0, 0, _("cannot find matching section for [%Zu] '%s'"),
+	  error (0, 0, _("cannot find matching section for [%zu] '%s'"),
 		 elf_ndxscn (scn), name);
 	}
     }
@@ -1270,7 +1270,7 @@ more sections in stripped file than debug file -- arguments reversed?"));
       sections[i].name = elf_strptr (stripped, stripped_shstrndx,
 				     shdr->sh_name);
       if (sections[i].name == NULL)
-	error (EXIT_FAILURE, 0, _("cannot read section [%Zu] name: %s"),
+	error (EXIT_FAILURE, 0, _("cannot read section [%zu] name: %s"),
 	       elf_ndxscn (scn), elf_errmsg (-1));
       sections[i].scn = scn;
       sections[i].outscn = NULL;
@@ -1390,7 +1390,7 @@ more sections in stripped file than debug file -- arguments reversed?"));
 
       if (sec == NULL)
 	error (EXIT_FAILURE, 0,
-	       _("cannot find matching section for [%Zu] '%s'"),
+	       _("cannot find matching section for [%zu] '%s'"),
 	       elf_ndxscn (scn), name);
 
       sec->outscn = scn;
@@ -1575,7 +1575,7 @@ more sections in stripped file than debug file -- arguments reversed?"));
 		  {
 		    if (shndx >= stripped_shnum)
 		      error (EXIT_FAILURE, 0,
-			     _("symbol [%Zu] has invalid section index"), i);
+			     _("symbol [%zu] has invalid section index"), i);
 
 		    shndx = ndx_section[shndx - 1];
 		    if (shndx < SHN_LORESERVE)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 09cd4e3..99b4d8f 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,16 @@
+2015-09-04  Chih-Hung Hsieh  <chh@google.com>
+
+	* asm-tst1.c (main): Replace %Z length modifier with %z.
+	* asm-tst2.c (main): Likewise.
+	* asm-tst3.c (main): Likewise.
+	* asm-tst4.c (main): Likewise.
+	* asm-tst5.c (main): Likewise.
+	* asm-tst6.c (main): Likewise.
+	* asm-tst7.c (main): Likewise.
+	* asm-tst8.c (main): Likewise.
+	* asm-tst9.c (main): Likewise.
+	* sectiondump.c (print_bytes): Likewise.
+
 2015-08-14  Mark Wielaard  <mjw@redhat.com>
 
 	* run-addr2line-alt-debugpath.sh: New test.
diff --git a/tests/asm-tst1.c b/tests/asm-tst1.c
index f611d66..9afc676 100644
--- a/tests/asm-tst1.c
+++ b/tests/asm-tst1.c
@@ -160,7 +160,7 @@ main (void)
       scn = elf_getscn (elf, cnt);
       if (scn == NULL)
 	{
-	  printf ("cannot get section %Zd: %s\n", cnt, elf_errmsg (-1));
+	  printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
 	}
@@ -168,7 +168,7 @@ main (void)
       shdr = gelf_getshdr (scn, &shdr_mem);
       if (shdr == NULL)
 	{
-	  printf ("cannot get section header for section %Zd: %s\n",
+	  printf ("cannot get section header for section %zd: %s\n",
 		  cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
@@ -177,7 +177,7 @@ main (void)
       if (strcmp (elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
 		  scnnames[cnt]) != 0)
 	{
-	  printf ("section %Zd's name differs: %s vs %s\n", cnt,
+	  printf ("section %zd's name differs: %s vs %s\n", cnt,
 		  elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
 		  scnnames[cnt]);
 	  result = 1;
@@ -185,7 +185,7 @@ main (void)
 
       if (shdr->sh_type != (cnt == 3 ? SHT_STRTAB : SHT_PROGBITS))
 	{
-	  printf ("section %Zd's type differs\n", cnt);
+	  printf ("section %zd's type differs\n", cnt);
 	  result = 1;
 	}
 
@@ -193,51 +193,51 @@ main (void)
 	  || (cnt == 2 && shdr->sh_flags != (SHF_ALLOC | SHF_WRITE))
 	  || (cnt == 3 && shdr->sh_flags != 0))
 	{
-	  printf ("section %Zd's flags differs\n", cnt);
+	  printf ("section %zd's flags differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_addr != 0)
 	{
-	  printf ("section %Zd's address differs\n", cnt);
+	  printf ("section %zd's address differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_offset != ((sizeof (Elf32_Ehdr) + 31) & ~31))
 	{
-	  printf ("section %Zd's offset differs\n", cnt);
+	  printf ("section %zd's offset differs\n", cnt);
 	  result = 1;
 	}
 
       if ((cnt != 3 && shdr->sh_size != 0)
 	  || (cnt == 3 && shdr->sh_size != 23))
 	{
-	  printf ("section %Zd's size differs\n", cnt);
+	  printf ("section %zd's size differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_link != 0)
 	{
-	  printf ("section %Zd's link differs\n", cnt);
+	  printf ("section %zd's link differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_info != 0)
 	{
-	  printf ("section %Zd's info differs\n", cnt);
+	  printf ("section %zd's info differs\n", cnt);
 	  result = 1;
 	}
 
       if ((cnt == 1 && shdr->sh_addralign != 32)
 	  || (cnt != 1 && shdr->sh_addralign != 1))
 	{
-	  printf ("section %Zd's addralign differs\n", cnt);
+	  printf ("section %zd's addralign differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_entsize != 0)
 	{
-	  printf ("section %Zd's entsize differs\n", cnt);
+	  printf ("section %zd's entsize differs\n", cnt);
 	  result = 1;
 	}
     }
diff --git a/tests/asm-tst2.c b/tests/asm-tst2.c
index 41bf13a..2556d0c 100644
--- a/tests/asm-tst2.c
+++ b/tests/asm-tst2.c
@@ -176,7 +176,7 @@ main (void)
       scn = elf_getscn (elf, cnt);
       if (scn == NULL)
 	{
-	  printf ("cannot get section %Zd: %s\n", cnt, elf_errmsg (-1));
+	  printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
 	}
@@ -184,7 +184,7 @@ main (void)
       shdr = gelf_getshdr (scn, &shdr_mem);
       if (shdr == NULL)
 	{
-	  printf ("cannot get section header for section %Zd: %s\n",
+	  printf ("cannot get section header for section %zd: %s\n",
 		  cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
@@ -193,7 +193,7 @@ main (void)
       if (strcmp (elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
 		  scnnames[cnt]) != 0)
 	{
-	  printf ("section %Zd's name differs: %s vs %s\n", cnt,
+	  printf ("section %zd's name differs: %s vs %s\n", cnt,
 		  elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
 		  scnnames[cnt]);
 	  result = 1;
@@ -201,20 +201,20 @@ main (void)
 
       if (shdr->sh_type != (cnt == 2 ? SHT_STRTAB : SHT_PROGBITS))
 	{
-	  printf ("section %Zd's type differs\n", cnt);
+	  printf ("section %zd's type differs\n", cnt);
 	  result = 1;
 	}
 
       if ((cnt == 1 && shdr->sh_flags != (SHF_ALLOC | SHF_WRITE))
 	  || (cnt == 2 && shdr->sh_flags != 0))
 	{
-	  printf ("section %Zd's flags differs\n", cnt);
+	  printf ("section %zd's flags differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_addr != 0)
 	{
-	  printf ("section %Zd's address differs\n", cnt);
+	  printf ("section %zd's address differs\n", cnt);
 	  result = 1;
 	}
 
@@ -225,7 +225,7 @@ main (void)
 				     + strlen ("two") + 1
 				     + strlen ("three") + 1)))
 	{
-	  printf ("section %Zd's offset differs\n", cnt);
+	  printf ("section %zd's offset differs\n", cnt);
 	  result = 1;
 	}
 
@@ -234,32 +234,32 @@ main (void)
 					 + strlen ("three") + 1))
 	  || (cnt == 2 && shdr->sh_size != 17))
 	{
-	  printf ("section %Zd's size differs\n", cnt);
+	  printf ("section %zd's size differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_link != 0)
 	{
-	  printf ("section %Zd's link differs\n", cnt);
+	  printf ("section %zd's link differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_info != 0)
 	{
-	  printf ("section %Zd's info differs\n", cnt);
+	  printf ("section %zd's info differs\n", cnt);
 	  result = 1;
 	}
 
       if ((cnt == 1 && shdr->sh_addralign != 16)
 	  || (cnt != 1 && shdr->sh_addralign != 1))
 	{
-	  printf ("section %Zd's addralign differs\n", cnt);
+	  printf ("section %zd's addralign differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_entsize != 0)
 	{
-	  printf ("section %Zd's entsize differs\n", cnt);
+	  printf ("section %zd's entsize differs\n", cnt);
 	  result = 1;
 	}
     }
diff --git a/tests/asm-tst3.c b/tests/asm-tst3.c
index acec1a4..e52cfbe 100644
--- a/tests/asm-tst3.c
+++ b/tests/asm-tst3.c
@@ -176,7 +176,7 @@ main (void)
       scn = elf_getscn (elf, cnt);
       if (scn == NULL)
 	{
-	  printf ("cannot get section %Zd: %s\n", cnt, elf_errmsg (-1));
+	  printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
 	}
@@ -184,7 +184,7 @@ main (void)
       shdr = gelf_getshdr (scn, &shdr_mem);
       if (shdr == NULL)
 	{
-	  printf ("cannot get section header for section %Zd: %s\n",
+	  printf ("cannot get section header for section %zd: %s\n",
 		  cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
@@ -193,7 +193,7 @@ main (void)
       if (strcmp (elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
 		  scnnames[cnt]) != 0)
 	{
-	  printf ("section %Zd's name differs: %s vs %s\n", cnt,
+	  printf ("section %zd's name differs: %s vs %s\n", cnt,
 		  elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
 		  scnnames[cnt]);
 	  result = 1;
@@ -201,20 +201,20 @@ main (void)
 
       if (shdr->sh_type != scntypes[cnt])
 	{
-	  printf ("section %Zd's type differs\n", cnt);
+	  printf ("section %zd's type differs\n", cnt);
 	  result = 1;
 	}
 
       if ((cnt == 1 && shdr->sh_flags != (SHF_ALLOC | SHF_WRITE))
 	  || (cnt != 1 && shdr->sh_flags != 0))
 	{
-	  printf ("section %Zd's flags differs\n", cnt);
+	  printf ("section %zd's flags differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_addr != 0)
 	{
-	  printf ("section %Zd's address differs\n", cnt);
+	  printf ("section %zd's address differs\n", cnt);
 	  result = 1;
 	}
 
diff --git a/tests/asm-tst4.c b/tests/asm-tst4.c
index 4788b79..52e9e20 100644
--- a/tests/asm-tst4.c
+++ b/tests/asm-tst4.c
@@ -62,7 +62,7 @@ main (void)
       AsmScn_t *scn;
 
       /* Create a unique name.  */
-      snprintf (buf, sizeof (buf), ".data.%Zu", cnt);
+      snprintf (buf, sizeof (buf), ".data.%zu", cnt);
 
       /* Create the section.  */
       scn = asm_newscn (ctx, buf, SHT_PROGBITS, SHF_ALLOC | SHF_WRITE);
diff --git a/tests/asm-tst5.c b/tests/asm-tst5.c
index d97d4be..5a29b01 100644
--- a/tests/asm-tst5.c
+++ b/tests/asm-tst5.c
@@ -64,7 +64,7 @@ main (void)
       AsmScn_t *scn;
 
       /* Create a unique name.  */
-      snprintf (buf, sizeof (buf), ".data.%Zu", cnt);
+      snprintf (buf, sizeof (buf), ".data.%zu", cnt);
 
       /* Create the section.  */
       scn = asm_newscn (ctx, buf, SHT_PROGBITS, SHF_ALLOC | SHF_WRITE);
@@ -77,7 +77,7 @@ main (void)
 	}
 
       /* Add a name.  */
-      snprintf (buf, sizeof (buf), "%Zu", cnt);
+      snprintf (buf, sizeof (buf), "%zu", cnt);
       if (asm_newsym (scn, buf, sizeof (uint32_t), STT_OBJECT,
 		      STB_GLOBAL) == NULL)
 	{
diff --git a/tests/asm-tst6.c b/tests/asm-tst6.c
index 35854d5..bd9b362 100644
--- a/tests/asm-tst6.c
+++ b/tests/asm-tst6.c
@@ -62,11 +62,11 @@ main (void)
       AsmScn_t *scn;
       AsmSym_t *sym;
 
-      snprintf (buf, sizeof (buf), ".grp%Zu", cnt);
+      snprintf (buf, sizeof (buf), ".grp%zu", cnt);
       grp = asm_newscngrp (ctx, buf, NULL, 0);
       if (grp == NULL)
 	{
-	  printf ("cannot section group %Zu: %s\n", cnt, asm_errmsg (-1));
+	  printf ("cannot section group %zu: %s\n", cnt, asm_errmsg (-1));
 	  asm_abort (ctx);
 	  return 1;
 	}
@@ -75,14 +75,14 @@ main (void)
 			      SHF_ALLOC | SHF_WRITE, grp);
       if (scn == NULL)
 	{
-	  printf ("cannot data section for group %Zu: %s\n",
+	  printf ("cannot data section for group %zu: %s\n",
 		  cnt, asm_errmsg (-1));
 	  asm_abort (ctx);
 	  return 1;
 	}
 
       /* Add a name.  */
-      snprintf (buf, sizeof (buf), "%Zu", cnt);
+      snprintf (buf, sizeof (buf), "%zu", cnt);
       sym = asm_newsym (scn, buf, sizeof (uint32_t), STT_OBJECT,
 			STB_GLOBAL);
       if (sym == NULL)
@@ -104,7 +104,7 @@ main (void)
       /* Now we have a symbol, use it as the signature.  */
       if (asm_scngrp_newsignature (grp, sym) != 0)
 	{
-	  printf ("cannot set signature for section group %Zu: %s\n",
+	  printf ("cannot set signature for section group %zu: %s\n",
 		  cnt, asm_errmsg (-1));
 	  asm_abort (ctx);
 	  return 1;
@@ -114,7 +114,7 @@ main (void)
       scn = asm_newscn_ingrp (ctx, ".stab", SHT_PROGBITS, 0, grp);
       if (scn == NULL)
 	{
-	  printf ("cannot stab section for group %Zu: %s\n",
+	  printf ("cannot stab section for group %zu: %s\n",
 		  cnt, asm_errmsg (-1));
 	  asm_abort (ctx);
 	  return 1;
diff --git a/tests/asm-tst7.c b/tests/asm-tst7.c
index a875eb4..00cb2bf 100644
--- a/tests/asm-tst7.c
+++ b/tests/asm-tst7.c
@@ -102,7 +102,7 @@ main (void)
       scn = elf_getscn (elf, cnt);
       if (scn == NULL)
 	{
-	  printf ("cannot get section %Zd: %s\n", cnt, elf_errmsg (-1));
+	  printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
 	}
@@ -110,7 +110,7 @@ main (void)
       shdr = gelf_getshdr (scn, &shdr_mem);
       if (shdr == NULL)
 	{
-	  printf ("cannot get section header for section %Zd: %s\n",
+	  printf ("cannot get section header for section %zd: %s\n",
 		  cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
diff --git a/tests/asm-tst8.c b/tests/asm-tst8.c
index 597c5cb..4fb0d99 100644
--- a/tests/asm-tst8.c
+++ b/tests/asm-tst8.c
@@ -103,7 +103,7 @@ main (void)
       scn = elf_getscn (elf, cnt);
       if (scn == NULL)
 	{
-	  printf ("cannot get section %Zd: %s\n", cnt, elf_errmsg (-1));
+	  printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
 	}
@@ -111,7 +111,7 @@ main (void)
       shdr = gelf_getshdr (scn, &shdr_mem);
       if (shdr == NULL)
 	{
-	  printf ("cannot get section header for section %Zd: %s\n",
+	  printf ("cannot get section header for section %zd: %s\n",
 		  cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
diff --git a/tests/asm-tst9.c b/tests/asm-tst9.c
index b9fcdd4..b6d0e43 100644
--- a/tests/asm-tst9.c
+++ b/tests/asm-tst9.c
@@ -210,7 +210,7 @@ main (void)
       escn = elf_getscn (elf, cnt);
       if (escn == NULL)
 	{
-	  printf ("cannot get section %Zd: %s\n", cnt, elf_errmsg (-1));
+	  printf ("cannot get section %zd: %s\n", cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
 	}
@@ -218,7 +218,7 @@ main (void)
       shdr = gelf_getshdr (escn, &shdr_mem);
       if (shdr == NULL)
 	{
-	  printf ("cannot get section header for section %Zd: %s\n",
+	  printf ("cannot get section header for section %zd: %s\n",
 		  cnt, elf_errmsg (-1));
 	  result = 1;
 	  continue;
@@ -227,7 +227,7 @@ main (void)
       if (strcmp (elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
 		  scnnames[cnt]) != 0)
 	{
-	  printf ("section %Zd's name differs: %s vs %s\n", cnt,
+	  printf ("section %zd's name differs: %s vs %s\n", cnt,
 		  elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name),
 		  scnnames[cnt]);
 	  result = 1;
@@ -235,20 +235,20 @@ main (void)
 
       if (shdr->sh_type != (cnt == 2 ? SHT_STRTAB : SHT_PROGBITS))
 	{
-	  printf ("section %Zd's type differs\n", cnt);
+	  printf ("section %zd's type differs\n", cnt);
 	  result = 1;
 	}
 
       if ((cnt == 1 && shdr->sh_flags != (SHF_ALLOC | SHF_WRITE))
 	  || (cnt == 2 && shdr->sh_flags != 0))
 	{
-	  printf ("section %Zd's flags differs\n", cnt);
+	  printf ("section %zd's flags differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_addr != 0)
 	{
-	  printf ("section %Zd's address differs\n", cnt);
+	  printf ("section %zd's address differs\n", cnt);
 	  result = 1;
 	}
 
@@ -257,39 +257,39 @@ main (void)
 	      && shdr->sh_offset != (((sizeof (Elf32_Ehdr) + 15) & ~15)
 				     + sizeof (expecteddata))))
 	{
-	  printf ("section %Zd's offset differs\n", cnt);
+	  printf ("section %zd's offset differs\n", cnt);
 	  result = 1;
 	}
 
       if ((cnt == 1 && shdr->sh_size != sizeof (expecteddata))
 	  || (cnt == 2 && shdr->sh_size != 17))
 	{
-	  printf ("section %Zd's size differs\n", cnt);
+	  printf ("section %zd's size differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_link != 0)
 	{
-	  printf ("section %Zd's link differs\n", cnt);
+	  printf ("section %zd's link differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_info != 0)
 	{
-	  printf ("section %Zd's info differs\n", cnt);
+	  printf ("section %zd's info differs\n", cnt);
 	  result = 1;
 	}
 
       if ((cnt == 1 && shdr->sh_addralign != 16)
 	  || (cnt != 1 && shdr->sh_addralign != 1))
 	{
-	  printf ("section %Zd's addralign differs\n", cnt);
+	  printf ("section %zd's addralign differs\n", cnt);
 	  result = 1;
 	}
 
       if (shdr->sh_entsize != 0)
 	{
-	  printf ("section %Zd's entsize differs\n", cnt);
+	  printf ("section %zd's entsize differs\n", cnt);
 	  result = 1;
 	}
 
@@ -299,14 +299,14 @@ main (void)
 
 	  if (data == NULL)
 	    {
-	      printf ("cannot get data of section %Zd\n", cnt);
+	      printf ("cannot get data of section %zd\n", cnt);
 	      result = 1;
 	    }
 	  else
 	    {
 	      if (data->d_size != sizeof (expecteddata))
 		{
-		  printf ("data block size of section %Zd wrong: got %Zd, "
+		  printf ("data block size of section %zd wrong: got %zd, "
 			  "expected 96\n", cnt, data->d_size);
 		  result = 1;
 		}
@@ -314,7 +314,7 @@ main (void)
 	      if (memcmp (data->d_buf, expecteddata, sizeof (expecteddata))
 		  != 0)
 		{
-		  printf ("data block content of section %Zd wrong\n", cnt);
+		  printf ("data block content of section %zd wrong\n", cnt);
 		  result = 1;
 		}
 	    }
diff --git a/tests/sectiondump.c b/tests/sectiondump.c
index f865954..3033fed 100644
--- a/tests/sectiondump.c
+++ b/tests/sectiondump.c
@@ -149,7 +149,7 @@ print_bytes (Elf_Data *data)
     {
       size_t inner;
 
-      printf ("%*Zx: ", sizeof (size_t) == 4 ? 8 : 16, (size_t) offset + cnt);
+      printf ("%*zx: ", sizeof (size_t) == 4 ? 8 : 16, (size_t) offset + cnt);
 
       for (inner = 0; inner < 16 && cnt + inner < size; ++inner)
 	printf (" %02hhx", buf[cnt + inner]);
@@ -172,7 +172,7 @@ print_symtab (Elf *elf, Elf_Data *data)
       GElf_Sym sym_mem;
       GElf_Sym *sym = gelf_getsym (data, cnt, &sym_mem);
 
-      printf ("%5Zu: %*" PRIx64 " %6" PRIx64 " %4d\n",
+      printf ("%5zu: %*" PRIx64 " %6" PRIx64 " %4d\n",
 	      cnt,
 	      class == ELFCLASS32 ? 8 : 16,
 	      sym->st_value,
-- 
1.8.3.1


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