bug-hurd
[Top][All Lists]
Advanced

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

[PATCH] Fix *printf specifier for user space mach ports.


From: Flavio Cruz
Subject: [PATCH] Fix *printf specifier for user space mach ports.
Date: Mon, 5 Dec 2022 01:34:56 -0500

mach_port_t are mach_port_name_t and thus require %u instead of %lu.
---
 boot/boot.c                   |  4 ++--
 exec/main.c                   |  2 +-
 ext2fs/ext2fs.c               |  2 +-
 ext2fs/pager.c                |  2 +-
 libdiskfs/boot-start.c        |  2 +-
 libpager/data-request.c       |  2 +-
 libpager/data-return.c        |  2 +-
 libpager/data-unlock.c        |  2 +-
 libshouldbeinlibc/portinfo.c  |  8 ++++----
 libshouldbeinlibc/xportinfo.c |  2 +-
 procfs/process.c              |  2 +-
 startup/startup.c             |  4 ++--
 utils/rpctrace.c              | 12 ++++++------
 13 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/boot/boot.c b/boot/boot.c
index f326e5b2..1f02947f 100644
--- a/boot/boot.c
+++ b/boot/boot.c
@@ -2032,7 +2032,7 @@ static void
 task_died (mach_port_t name)
 {
   if (verbose > 1)
-    fprintf (stderr, "Task '%lu' died.\r\n", name);
+    fprintf (stderr, "Task '%u' died.\r\n", name);
 
   hurd_ihash_remove (&task_ihash, (hurd_ihash_key_t) name);
 }
@@ -2050,7 +2050,7 @@ S_mach_notify_new_task (mach_port_t notify,
     return EOPNOTSUPP;
 
   if (verbose > 1)
-    fprintf (stderr, "Task '%lu' created by task '%lu'.\r\n", task, parent);
+    fprintf (stderr, "Task '%u' created by task '%u'.\r\n", task, parent);
 
   err = mach_port_request_notification (mach_task_self (), task,
                                         MACH_NOTIFY_DEAD_NAME, 0,
diff --git a/exec/main.c b/exec/main.c
index 9825d9cf..9021e45c 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -150,7 +150,7 @@ trivfs_append_args (struct trivfs_control *fsys,
 
   if (MACH_PORT_VALID (opt_device_master))
     {
-      asprintf (&opt, "--device-master-port=%lu", opt_device_master);
+      asprintf (&opt, "--device-master-port=%u", opt_device_master);
 
       if (opt)
        {
diff --git a/ext2fs/ext2fs.c b/ext2fs/ext2fs.c
index 50435c76..5beb3906 100644
--- a/ext2fs/ext2fs.c
+++ b/ext2fs/ext2fs.c
@@ -232,7 +232,7 @@ main (int argc, char **argv)
   if (store->size < SBLOCK_OFFS + SBLOCK_SIZE)
     ext2_panic ("device too small for superblock (%Ld bytes)", store->size);
   if (store->log2_blocks_per_page < 0)
-    ext2_panic ("device block size (%zu) greater than page size (%zd)",
+    ext2_panic ("device block size (%zu) greater than page size (%lu)",
                store->block_size, vm_page_size);
 
   /* Map the entire disk. */
diff --git a/ext2fs/pager.c b/ext2fs/pager.c
index baf2d4b7..00544cfb 100644
--- a/ext2fs/pager.c
+++ b/ext2fs/pager.c
@@ -905,7 +905,7 @@ static void
 disk_cache_init (void)
 {
   if (block_size != vm_page_size)
-    ext2_panic ("Block size %u != vm_page_size %u",
+    ext2_panic ("Block size %u != vm_page_size %lu",
                block_size, vm_page_size);
 
   pthread_mutex_init (&disk_cache_lock, NULL);
diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index 89d09d65..f245200d 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -248,7 +248,7 @@ diskfs_start_bootstrap ()
       while (err == KERN_NAME_EXISTS);
       diskfs_kernel_task = MACH_PORT_NULL;
 
-      len = snprintf (buf, sizeof buf, "--kernel-task=%lu", kernel_task_name);
+      len = snprintf (buf, sizeof buf, "--kernel-task=%u", kernel_task_name);
       assert_backtrace (len > 0);
       assert_backtrace ((size_t) len < sizeof buf);
       /* Insert as second argument.  */
diff --git a/libpager/data-request.c b/libpager/data-request.c
index 7069fc84..b06b7f18 100644
--- a/libpager/data-request.c
+++ b/libpager/data-request.c
@@ -49,7 +49,7 @@ _pager_S_memory_object_data_request (struct pager *p,
     }
   if (length != __vm_page_size)
     {
-      printf ("incg data request: bad length size %zd\n", length);
+      printf ("incg data request: bad length size %lu\n", length);
       goto release_out;
     }
   if (offset % __vm_page_size)
diff --git a/libpager/data-return.c b/libpager/data-return.c
index 4c4affe8..79c012aa 100644
--- a/libpager/data-return.c
+++ b/libpager/data-return.c
@@ -60,7 +60,7 @@ _pager_do_write_request (struct pager *p,
     }
   if (length % __vm_page_size)
     {
-      printf ("incg data return: bad length size %zd\n", length);
+      printf ("incg data return: bad length size %lu\n", length);
       goto release_out;
     }
   if (offset % __vm_page_size)
diff --git a/libpager/data-unlock.c b/libpager/data-unlock.c
index 077e673f..d155ff12 100644
--- a/libpager/data-unlock.c
+++ b/libpager/data-unlock.c
@@ -58,7 +58,7 @@ _pager_S_memory_object_data_unlock (struct pager *p,
     }
   if (length != __vm_page_size)
     {
-      printf ("incg data unlock: bad length size %zd\n", length);
+      printf ("incg data unlock: bad length size %lu\n", length);
       goto out;
     }
 
diff --git a/libshouldbeinlibc/portinfo.c b/libshouldbeinlibc/portinfo.c
index a023446a..42b22081 100644
--- a/libshouldbeinlibc/portinfo.c
+++ b/libshouldbeinlibc/portinfo.c
@@ -72,7 +72,7 @@ print_port_info (mach_port_t name, mach_port_type_t type, 
task_t task,
        return err;
     }
 
-  fprintf (stream, hex_names ? "%#6lx: " : "%6lu: ", name);
+  fprintf (stream, hex_names ? "%#6x: " : "%6u: ", name);
 
   if (type & MACH_PORT_TYPE_RECEIVE)
     {
@@ -480,7 +480,7 @@ print_port_info (mach_port_t name, mach_port_type_t type, 
task_t task,
              fprintf (stream, " (");
              if (status.mps_pset != MACH_PORT_NULL)
                fprintf (stream,
-                        hex_names ? "port-set: %#lx, " : "port-set: %lu, ",
+                        hex_names ? "port-set: %#x, " : "port-set: %u, ",
                         status.mps_pset);
              fprintf (stream, "seqno: %zu", status.mps_seqno);
              if (status.mps_mscount)
@@ -514,9 +514,9 @@ print_port_info (mach_port_t name, mach_port_type_t type, 
task_t task,
                fprintf (stream, " (empty)");
              else
                {
-                 fprintf (stream, hex_names ? " (%#lx" : " (%lu", members[0]);
+                 fprintf (stream, hex_names ? " (%#x" : " (%u", members[0]);
                  for (i = 1; i < members_len; i++)
-                   fprintf (stream, hex_names ? ", %#lx" : ", %lu",
+                   fprintf (stream, hex_names ? ", %#x" : ", %u",
                             members[i]);
                  fprintf (stream, ")");
                  munmap ((caddr_t) members, members_len * sizeof *members);
diff --git a/libshouldbeinlibc/xportinfo.c b/libshouldbeinlibc/xportinfo.c
index 47e6dd9a..2a6d6f69 100644
--- a/libshouldbeinlibc/xportinfo.c
+++ b/libshouldbeinlibc/xportinfo.c
@@ -35,7 +35,7 @@ print_xlated_port_info (mach_port_t name, mach_port_type_t 
type,
   error_t err = port_name_xlator_xlate (x, name, type, &name, &type);
   if (! err)
     {
-      fprintf (stream, (show & PORTINFO_HEX_NAMES) ? "%#6lx => " : "%6lu => ",
+      fprintf (stream, (show & PORTINFO_HEX_NAMES) ? "%#6x => " : "%6u => ",
               old_name);
       err = print_port_info (name, type, x->to_task, show, stream);
     }
diff --git a/procfs/process.c b/procfs/process.c
index 6e4c1515..f608bed6 100644
--- a/procfs/process.c
+++ b/procfs/process.c
@@ -191,7 +191,7 @@ process_file_gc_maps (struct proc_stat *ps, char **contents)
          else
            mach_port_deallocate (mach_task_self (), obj);
 
-         fprintf (s, "[mem_obj=%lu]\n", obj);
+         fprintf (s, "[mem_obj=%u]\n", obj);
        }
       else
        fprintf (s, "\n");
diff --git a/startup/startup.c b/startup/startup.c
index 1e3a65fb..f4636323 100644
--- a/startup/startup.c
+++ b/startup/startup.c
@@ -497,7 +497,7 @@ argz_task_insert_right (char **argz, size_t *argz_len, 
task_t task,
     }
   while (err == KERN_NAME_EXISTS);
 
-  if (asprintf (&arg, "--%s=%lu", argument, name) < 0)
+  if (asprintf (&arg, "--%s=%u", argument, name) < 0)
     return errno;
 
   err = argz_add (argz, argz_len, arg);
@@ -1636,7 +1636,7 @@ do_mach_notify_dead_name (mach_port_t notify_port,
                   boots[i].name);
            crash_mach ();
          }
-      error (0, 0, "BUG!  Unexpected dead-name notification (name %#lx)",
+      error (0, 0, "BUG!  Unexpected dead-name notification (name %#x)",
             name);
       crash_mach ();
     }
diff --git a/utils/rpctrace.c b/utils/rpctrace.c
index b4de175c..f47d179a 100644
--- a/utils/rpctrace.c
+++ b/utils/rpctrace.c
@@ -353,7 +353,7 @@ new_send_wrapper (struct receiver_info *receive, task_t 
task,
   assert_perror_backtrace (err);
 
   TRACED_INFO (info)->name = 0;
-  asprintf (&TRACED_INFO (info)->name, "  %lu<--%lu(pid%d)", 
+  asprintf (&TRACED_INFO (info)->name, "  %u<--%u(pid%d)",
            receive->forward, TRACED_INFO (info)->pi.port_right, task2pid 
(task));
   TRACED_INFO (info)->type = MACH_MSG_TYPE_MOVE_SEND;
   info->task = task;
@@ -979,7 +979,7 @@ wrap_all_threads (task_t task)
                                                  task, &new_thread_port);
          free (TRACED_INFO (thread_send_wrapper)->name);
          asprintf (&TRACED_INFO (thread_send_wrapper)->name,
-                   "thread%lu(pid%d)", threads[i], task2pid (task));
+                   "thread%u(pid%d)", threads[i], task2pid (task));
 
          err = mach_port_insert_right (mach_task_self (),
                                        new_thread_port, new_thread_port,
@@ -1031,7 +1031,7 @@ wrap_new_thread (mach_msg_header_t *inp, struct req_info 
*req)
   mach_port_deallocate (mach_task_self (), reply->child_thread);
 
   free (TRACED_INFO (send_wrapper)->name);
-  asprintf (&TRACED_INFO (send_wrapper)->name, "thread%lu(pid%d)",
+  asprintf (&TRACED_INFO (send_wrapper)->name, "thread%u(pid%d)",
            thread_port, task2pid (req->from));
   ports_port_deref (send_wrapper);
 }
@@ -1078,10 +1078,10 @@ wrap_new_task (mach_msg_header_t *inp, struct req_info 
*req)
 
   pid = task2pid (task_port);
   free (TRACED_INFO (task_wrapper1)->name);
-  asprintf (&TRACED_INFO (task_wrapper1)->name, "task%lu(pid%d)",
+  asprintf (&TRACED_INFO (task_wrapper1)->name, "task%u(pid%d)",
            task_port, task2pid (req->from));
   free (TRACED_INFO (task_wrapper2)->name);
-  asprintf (&TRACED_INFO (task_wrapper2)->name, "task%lu(pid%d)",
+  asprintf (&TRACED_INFO (task_wrapper2)->name, "task%u(pid%d)",
            task_port, pid);
   ports_port_deref (task_wrapper1);
 }
@@ -1648,7 +1648,7 @@ traced_spawn (char **argv, char **envp)
   ti = new_send_wrapper (receive_ti, traced_task, &task_wrapper);
   ti->task = traced_task;
   free (TRACED_INFO (ti)->name);
-  asprintf (&TRACED_INFO (ti)->name, "task%lu(pid%d)", traced_task, pid);
+  asprintf (&TRACED_INFO (ti)->name, "task%u(pid%d)", traced_task, pid);
 
   /* Replace the task's kernel port with the wrapper.  When this task calls
      `mach_task_self ()', it will get our wrapper send right instead of its
-- 
2.37.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]