]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
eventfd.2, mprotect.2, pidfd_open.2, spu_run.2, timer_create.2, bswap.3, dl_iterate_p...
authorAlejandro Colomar <colomar.6.4.3@gmail.com>
Fri, 11 Sep 2020 20:53:51 +0000 (22:53 +0200)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Sat, 12 Sep 2020 06:38:20 +0000 (08:38 +0200)
Use printf()'s '#' flag character to prepend the string "0x".

However, when the number is printed in uppercase, and the prefix
is in lowercase, the string "0x" needs to be manually written.

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
12 files changed:
man2/eventfd.2
man2/mprotect.2
man2/pidfd_open.2
man2/spu_run.2
man2/timer_create.2
man3/bswap.3
man3/dl_iterate_phdr.3
man3/endian.3
man3/pthread_attr_init.3
man3/pthread_getattr_np.3
man4/vcs.4
man7/rtld-audit.7

index 71e9d85b4cc78cdf188e213c8acf903e3828d6fe..375f4823b7c83bfca67a20664707dc589b06d1f7 100644 (file)
@@ -431,7 +431,7 @@ main(int argc, char *argv[])
         s = read(efd, &u, sizeof(uint64_t));
         if (s != sizeof(uint64_t))
             handle_error("read");
-        printf("Parent read %"PRIu64" (0x%"PRIx64") from efd\en", u, u);
+        printf("Parent read %"PRIu64" (%#"PRIx64") from efd\en", u, u);
         exit(EXIT_SUCCESS);
 
     case \-1:
index 556ee9446759e615e6382109f1e55a2dad37ddcf..47d25030351149e7273f83b0122cf8aa80a06b6b 100644 (file)
@@ -326,7 +326,7 @@ handler(int sig, siginfo_t *si, void *unused)
        Nevertheless, we use printf() here as a simple way of
        showing that the handler was called. */
 
-    printf("Got SIGSEGV at address: 0x%lx\en",
+    printf("Got SIGSEGV at address: %#lx\en",
             (long) si\->si_addr);
     exit(EXIT_FAILURE);
 }
@@ -354,7 +354,7 @@ main(int argc, char *argv[])
     if (buffer == NULL)
         handle_error("memalign");
 
-    printf("Start of region:        0x%lx\en", (long) buffer);
+    printf("Start of region:        %#lx\en", (long) buffer);
 
     if (mprotect(buffer + pagesize * 2, pagesize,
                 PROT_READ) == \-1)
index ecdb98b1bb4ea3a396a67239c859b15a9ba8879a..0256d6d8cdc87653a1c3693f6560584c678c99db 100644 (file)
@@ -253,7 +253,7 @@ main(int argc, char *argv[])
         exit(EXIT_FAILURE);
     }
 
-    printf("Events (0x%x): POLLIN is %sset\en", pollfd.revents,
+    printf("Events (%#x): POLLIN is %sset\en", pollfd.revents,
             (pollfd.revents & POLLIN) ? "" : "not ");
 
     close(pidfd);
index 8346d21b745f207317e69893e8930ae4172ec4bd..b6bc2c1315805b1fd1dd772680cf49cd2cee702c 100644 (file)
@@ -254,7 +254,7 @@ int main(void)
      *   0x00000002 (spu was stopped due to stop\-and\-signal)
      * | 0x12340000 (the stop\-and\-signal code)
      */
-    printf("SPU Status: 0x%08x\en", spu_status);
+    printf("SPU Status: %#08x\en", spu_status);
 
     exit(EXIT_SUCCESS);
 }
index 9c990773901c3d2146e5f614d37b419521cdc481..05482f6d98866a090ebe9d70fa9b5e3b6fe1a828 100644 (file)
@@ -390,7 +390,7 @@ print_siginfo(siginfo_t *si)
     tidp = si\->si_value.sival_ptr;
 
     printf("    sival_ptr = %p; ", si\->si_value.sival_ptr);
-    printf("    *sival_ptr = 0x%lx\en", (unsigned long) *tidp);
+    printf("    *sival_ptr = %#lx\en", (unsigned long) *tidp);
 
     or = timer_getoverrun(*tidp);
     if (or == \-1)
@@ -454,7 +454,7 @@ main(int argc, char *argv[])
     if (timer_create(CLOCKID, &sev, &timerid) == \-1)
         errExit("timer_create");
 
-    printf("timer ID is 0x%lx\en", (unsigned long) timerid);
+    printf("timer ID is %#lx\en", (unsigned long) timerid);
 
     /* Start the timer */
 
index ce847580aa18342f5102202cb00c2481fa16a3f3..722cac806e5d4d3571c955340f14c8ef40b897bc 100644 (file)
@@ -73,7 +73,7 @@ main(int argc, char *argv[])
     }
 
     x = strtoull(argv[1], NULL, 0);
-    printf("0x%" PRIx64 " ==> 0x%" PRIx64 "\en", x, bswap_64(x));
+    printf("%#" PRIx64 " ==> %#" PRIx64 "\en", x, bswap_64(x));
 
     exit(EXIT_SUCCESS);
 }
index 62a3596a3f8ed500d3f9eb1b3852023827824eff..70206a0ba8d4fd8092e2132c543e58925d933c38 100644 (file)
@@ -325,14 +325,14 @@ callback(struct dl_phdr_info *info, size_t size, void *data)
                 (p_type == PT_GNU_STACK) ? "PT_GNU_STACK" :
                 (p_type == PT_GNU_RELRO) ? "PT_GNU_RELRO" : NULL;
 
-        printf("    %2d: [%14p; memsz:%7lx] flags: 0x%x; ", j,
+        printf("    %2d: [%14p; memsz:%7lx] flags: %#x; ", j,
                 (void *) (info\->dlpi_addr + info\->dlpi_phdr[j].p_vaddr),
                 info\->dlpi_phdr[j].p_memsz,
                 info\->dlpi_phdr[j].p_flags);
         if (type != NULL)
             printf("%s\en", type);
         else
-            printf("[other (0x%x)]\en", p_type);
+            printf("[other (%#x)]\en", p_type);
     }
 
     return 0;
index bdf1efd7e082f5017807622f141ccaa32b706239..4a2b29882e3f716cd864596a22b63397a1506c7c 100644 (file)
@@ -164,9 +164,9 @@ main(int argc, char *argv[])
     x.arr[2] = 0x33;
     x.arr[3] = 0x44;   /* Highest-address byte */
 
-    printf("x.u32 = 0x%x\en", x.u32);
-    printf("htole32(x.u32) = 0x%x\en", htole32(x.u32));
-    printf("htobe32(x.u32) = 0x%x\en", htobe32(x.u32));
+    printf("x.u32 = %#x\en", x.u32);
+    printf("htole32(x.u32) = %#x\en", htole32(x.u32));
+    printf("htobe32(x.u32) = %#x\en", htobe32(x.u32));
 
     exit(EXIT_SUCCESS);
 }
index ed7faaff0e98a1fb3a85b3d67a3ad715faea79cd..815b45de86f81de67421d1360fb1d744fd61cc8a 100644 (file)
@@ -228,7 +228,7 @@ display_pthread_attr(pthread_attr_t *attr, char *prefix)
     if (s != 0)
         handle_error_en(s, "pthread_attr_getstack");
     printf("%sStack address       = %p\en", prefix, stkaddr);
-    printf("%sStack size          = 0x%zx bytes\en", prefix, v);
+    printf("%sStack size          = %#zx bytes\en", prefix, v);
 }
 
 static void *
index be957607e0cc7fd060d1cfedbc96186278acab2f..01538526b041c3135a4cb6b8a16afa3dacefb284 100644 (file)
@@ -222,7 +222,7 @@ display_stack_related_attributes(pthread_attr_t *attr, char *prefix)
     if (stack_size > 0)
         printf(" (EOS = %p)", (char *) stack_addr + stack_size);
     printf("\en");
-    printf("%sStack size          = 0x%zx (%zu) bytes\en",
+    printf("%sStack size          = %#zx (%zu) bytes\en",
             prefix, stack_size, stack_size);
 }
 
index 6a67eb4131b69374984efaa411c002fc15bc5aae..bfa92aaea1ecf28c68844b94eddd95e34a70aa95 100644 (file)
@@ -177,7 +177,7 @@ main(void)
     if (s & mask)
         ch |= 0x100;
     attrib = ((s & \(timask) >> 8);
-    printf("ch=0x%03x attrib=0x%02x\en", ch, attrib);
+    printf("ch=%#03x attrib=%#02x\en", ch, attrib);
     s \(ha= 0x1000;
     (void) lseek(fd, \-2, SEEK_CUR);
     (void) write(fd, &s, 2);
index c6a4c19bfded2e04f9a4cd9fb93961aa77271d1b..f90731261ebd64f62f199952a0b5d11e44c59134 100644 (file)
@@ -572,7 +572,7 @@ la_symbind32(Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
 {
     printf("la_symbind32(): symname = %s; sym\->st_value = %p\en",
             symname, sym\->st_value);
-    printf("        ndx = %d; flags = 0x%x", ndx, *flags);
+    printf("        ndx = %d; flags = %#x", ndx, *flags);
     printf("; refcook = %p; defcook = %p\en", refcook, defcook);
 
     return sym\->st_value;
@@ -584,7 +584,7 @@ la_symbind64(Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
 {
     printf("la_symbind64(): symname = %s; sym\->st_value = %p\en",
             symname, sym\->st_value);
-    printf("        ndx = %d; flags = 0x%x", ndx, *flags);
+    printf("        ndx = %d; flags = %#x", ndx, *flags);
     printf("; refcook = %p; defcook = %p\en", refcook, defcook);
 
     return sym\->st_value;