bug-hurd
[Top][All Lists]
Advanced

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

[PATCH 14/41] utils: Port to x86_64


From: Sergey Bugaev
Subject: [PATCH 14/41] utils: Port to x86_64
Date: Tue, 9 May 2023 00:31:09 +0300

---
 utils/fakeauth.c  | 36 +++++++++++++++++++++---------------
 utils/frobauth.h  |  2 +-
 utils/fsysopts.c  |  5 +++--
 utils/ftpdir.c    |  3 ++-
 utils/login.c     |  2 +-
 utils/pids.c      |  9 +++++----
 utils/pids.h      | 11 +++++++----
 utils/ps.c        |  2 +-
 utils/rpctrace.c  |  8 ++++----
 utils/settrans.c  |  5 +++--
 utils/showtrans.c |  2 +-
 utils/storeinfo.c |  8 +++++---
 utils/vminfo.c    | 22 +++++++++++-----------
 13 files changed, 65 insertions(+), 50 deletions(-)

diff --git a/utils/fakeauth.c b/utils/fakeauth.c
index 5669f624..cd4ad565 100644
--- a/utils/fakeauth.c
+++ b/utils/fakeauth.c
@@ -69,7 +69,8 @@ destroy_authhandle (void *p)
 /* id management.  */
 
 static inline void
-idvec_copyout (struct idvec *idvec, uid_t **ids, size_t *nids)
+idvec_copyout (struct idvec *idvec, uid_t **ids,
+              mach_msg_type_number_t *nids)
 {
   if (idvec->num > *nids)
     *ids = idvec->ids;
@@ -86,13 +87,13 @@ idvec_copyout (struct idvec *idvec, uid_t **ids, size_t 
*nids)
 kern_return_t
 S_auth_getids (struct authhandle *auth,
               uid_t **euids,
-              size_t *neuids,
+              mach_msg_type_number_t *neuids,
               uid_t **auids,
-              size_t *nauids,
+              mach_msg_type_number_t *nauids,
               uid_t **egids,
-              size_t *negids,
+              mach_msg_type_number_t *negids,
               uid_t **agids,
-              size_t *nagids)
+              mach_msg_type_number_t *nagids)
 {
   if (! auth)
     return EOPNOTSUPP;
@@ -105,17 +106,22 @@ S_auth_getids (struct authhandle *auth,
 /* Implement auth_makeauth as described in <hurd/auth.defs>. */
 kern_return_t
 S_auth_makeauth (struct authhandle *auth,
-                const mach_port_t *authpts, size_t nauths,
-                const uid_t *euids, size_t neuids,
-                const uid_t *auids, size_t nauids,
-                const uid_t *egids, size_t negids,
-                const uid_t *agids, size_t nagids,
+                const mach_port_t *authpts,
+                mach_msg_type_number_t nauths,
+                const uid_t *euids,
+                mach_msg_type_number_t neuids,
+                const uid_t *auids,
+                mach_msg_type_number_t nauids,
+                const uid_t *egids,
+                mach_msg_type_number_t negids,
+                const uid_t *agids,
+                mach_msg_type_number_t nagids,
                 mach_port_t *newhandle)
 {
   struct authhandle *newauth, *auths[1 + nauths];
   int hasroot = 0;
   error_t err;
-  size_t i, j;
+  mach_msg_type_number_t i, j;
 
   if (!auth)
     return EOPNOTSUPP;
@@ -266,13 +272,13 @@ S_auth_server_authenticate (struct authhandle *serverauth,
                            mach_port_t newport,
                            mach_msg_type_name_t newport_type,
                            uid_t **euids,
-                           size_t *neuids,
+                           mach_msg_type_number_t *neuids,
                            uid_t **auids,
-                           size_t *nauids,
+                           mach_msg_type_number_t *nauids,
                            uid_t **egids,
-                           size_t *negids,
+                           mach_msg_type_number_t *negids,
                            uid_t **agids,
-                           size_t *nagids)
+                           mach_msg_type_number_t *nagids)
 {
   if (! serverauth)
     return EOPNOTSUPP;
diff --git a/utils/frobauth.h b/utils/frobauth.h
index 2b9c78f1..b14a9707 100644
--- a/utils/frobauth.h
+++ b/utils/frobauth.h
@@ -30,7 +30,7 @@ struct frobauth
 {
   struct ugids ugids;
   pid_t *pids;
-  size_t num_pids;
+  mach_msg_type_number_t num_pids;
   int verbose, dry_run;                /* User options */
   uid_t default_user;          /* If none specified; -1 means none.  */
   int require_ids;             /* If true, require some ids be specified. */
diff --git a/utils/fsysopts.c b/utils/fsysopts.c
index f3458a03..39037569 100644
--- a/utils/fsysopts.c
+++ b/utils/fsysopts.c
@@ -117,10 +117,11 @@ main(int argc, char *argv[])
     }
   else
     {
-      err = file_get_fs_options (node, &argz, &argz_len);
+      mach_msg_type_number_t argz_size = 0;
+      err = file_get_fs_options (node, &argz, &argz_size);
       if (err)
        error (5, err, "%s", node_name);
-      argz_stringify (argz, argz_len, ' ');
+      argz_stringify (argz, argz_size, ' ');
       puts (argz);
     }
 
diff --git a/utils/ftpdir.c b/utils/ftpdir.c
index 4ccb821d..86ef58f2 100644
--- a/utils/ftpdir.c
+++ b/utils/ftpdir.c
@@ -22,6 +22,7 @@
 #include <error.h>
 #include <argp.h>
 #include <time.h>
+#include <inttypes.h>
 #include <netdb.h>
 
 #include <version.h>
@@ -202,7 +203,7 @@ pdirent (const char *name, const struct stat *st, const 
char *symlink_target,
 {
   char timebuf[20];
   strftime (timebuf, sizeof timebuf, "%Y-%m-%d %H:%M", localtime 
(&st->st_mtime));
-  printf ("%6o %2d %5d %5d %6lld  %s  %s\n",
+  printf ("%6o %2ld %5d %5d %6" PRIi64 "  %s  %s\n",
          st->st_mode, st->st_nlink, st->st_uid, st->st_gid, st->st_size,
          timebuf, name);
   if (symlink_target)
diff --git a/utils/login.c b/utils/login.c
index 5fd5afc7..3134c4aa 100644
--- a/utils/login.c
+++ b/utils/login.c
@@ -285,7 +285,7 @@ static void
 kill_login (process_t proc_server, pid_t pid, int sig)
 {
   error_t err;
-  size_t num_pids;
+  mach_msg_type_number_t num_pids;
   pid_t self = getpid ();
 
   do
diff --git a/utils/pids.c b/utils/pids.c
index 82b75d1a..60067d9b 100644
--- a/utils/pids.c
+++ b/utils/pids.c
@@ -43,11 +43,12 @@ proc_server (void)
 /* Add the pids returned in vm_allocated memory by calling PIDS_FN with ID as
    an argument to PIDS and NUM_PIDS, reallocating it in malloced memory.  */
 error_t
-add_fn_pids (pid_t **pids, size_t *num_pids, unsigned id,
+add_fn_pids (pid_t **pids, mach_msg_type_number_t *num_pids, unsigned id,
             error_t (*pids_fn)(process_t proc, pid_t id,
-                               pid_t **pids, size_t *num_pids))
+                               pid_t **pids,
+                               mach_msg_type_number_t *num_pids))
 {
-  size_t num_new_pids = 25;
+  mach_msg_type_number_t num_new_pids = 25;
   pid_t _new_pids[num_new_pids], *new_pids = _new_pids;
   error_t err = (*pids_fn)(proc_server (), id, &new_pids, &num_new_pids);
 
@@ -73,7 +74,7 @@ add_fn_pids (pid_t **pids, size_t *num_pids, unsigned id,
 
 /* Add PID to PIDS and NUM_PIDS, reallocating it in malloced memory.  */
 error_t
-add_pid (pid_t **pids, size_t *num_pids, pid_t pid)
+add_pid (pid_t **pids, mach_msg_type_number_t *num_pids, pid_t pid)
 {
   size_t new_sz = *num_pids + 1;
   pid_t *new = realloc (*pids, new_sz * sizeof (pid_t));
diff --git a/utils/pids.h b/utils/pids.h
index dcf87e81..f36f692a 100644
--- a/utils/pids.h
+++ b/utils/pids.h
@@ -23,19 +23,22 @@
 
 /* Add the pids returned in vm_allocated memory by calling PIDS_FN with ID as
    an argument to PIDS and NUM_PIDS, reallocating it in malloced memory.  */
-extern error_t add_fn_pids (pid_t **pids, size_t *num_pids, unsigned id,
+extern error_t add_fn_pids (pid_t **pids, mach_msg_type_number_t *num_pids,
+                           unsigned id,
                            error_t (*pids_fn)(process_t proc, pid_t id,
-                                              pid_t **pids, size_t *num_pids));
+                                              pid_t **pids,
+                                              mach_msg_type_number_t 
*num_pids));
 
 /* Add PID to PIDS and NUM_PIDS, reallocating it in malloced memory.  */
-extern error_t add_pid (pid_t **pids, size_t *num_pids, pid_t pid);
+extern error_t add_pid (pid_t **pids, mach_msg_type_number_t *num_pids,
+                       pid_t pid);
 
 /* Params to be passed as the input when parsing PIDS_ARGP.  */
 struct pids_argp_params
 {
   /* Array to be extended with parsed pids.  */
   pid_t **pids;
-  size_t *num_pids;
+  mach_msg_type_number_t *num_pids;
 
   /* If true, parse non-option arguments as pids.  */
   int parse_pid_args;
diff --git a/utils/ps.c b/utils/ps.c
index 91a00a36..6fd4e64e 100644
--- a/utils/ps.c
+++ b/utils/ps.c
@@ -188,7 +188,7 @@ main(int argc, char *argv[])
   int posix_fmt = 0;           /* Use a posix_fmt-style format string.  */
   int top = 0;                 /* Number of entries to output.  */
   pid_t *pids = 0;             /* User-specified pids.  */
-  size_t num_pids = 0;
+  mach_msg_type_number_t num_pids = 0;
   struct pids_argp_params pids_argp_params = { &pids, &num_pids, 1 };
 
   /* Add a user who's processes should be printed out.  */
diff --git a/utils/rpctrace.c b/utils/rpctrace.c
index f4d103e8..589ce8f8 100644
--- a/utils/rpctrace.c
+++ b/utils/rpctrace.c
@@ -961,7 +961,7 @@ wrap_all_threads (task_t task)
   struct sender_info *thread_send_wrapper;
   struct receiver_info *thread_receiver_info;
   thread_t *threads;
-  size_t nthreads;
+  mach_msg_type_number_t nthreads;
   error_t err;
 
   err = task_threads (task, &threads, &nthreads);
@@ -1134,7 +1134,7 @@ trace_and_forward (mach_msg_header_t *inp, 
mach_msg_header_t *outp)
            MACH_MSGH_BITS_REMOTE (inp->msgh_bits),
            is_notification (inp)? MACH_MSG_TYPE_MOVE_SEND_ONCE: info->type)
            | MACH_MSGH_BITS_OTHER (inp->msgh_bits);
-         inp->msgh_local_port = ports_payload_get_name ((unsigned int) info);
+         inp->msgh_local_port = ports_payload_get_name ((uintptr_t) info);
        }
     }
   else
@@ -1538,7 +1538,7 @@ print_data (mach_msg_type_name_t type,
          /* We encountered a non-printable character.  Print anything
             that has not been printed so far.  */
          if (p < q)
-           fprintf (ostream, "%.*s", q - p, p);
+           fprintf (ostream, "%.*s", (int) (q - p), p);
 
          char c = escape_sequences[*((const unsigned char *) q)];
          if (c)
@@ -1552,7 +1552,7 @@ print_data (mach_msg_type_name_t type,
 
       /* Print anything that has not been printed so far.  */
       if (p < q)
-       fprintf (ostream, "%.*s", q - p, p);
+       fprintf (ostream, "%.*s", (int) (q - p), p);
       fprintf (ostream, "\"");
       return;
 
diff --git a/utils/settrans.c b/utils/settrans.c
index adeb9b3c..9b3af312 100644
--- a/utils/settrans.c
+++ b/utils/settrans.c
@@ -308,14 +308,15 @@ main(int argc, char *argv[])
 
       char buf[1024];
       argz = buf;
-      argz_len = sizeof (buf);
+      mach_msg_type_number_t argz_size = sizeof (buf);
 
-      err = file_get_translator (node, &argz, &argz_len);
+      err = file_get_translator (node, &argz, &argz_size);
       if (err == EINVAL)
        error (4, 0, "%s: no passive translator record found", node_name);
       if (err)
        error (4, err, "%s", node_name);
 
+      argz_len = argz_size;
       mach_port_deallocate (mach_task_self (), node);
     }
 
diff --git a/utils/showtrans.c b/utils/showtrans.c
index aa55f14d..d77e8f25 100644
--- a/utils/showtrans.c
+++ b/utils/showtrans.c
@@ -67,7 +67,7 @@ main (int argc, char *argv[])
       else
        {
          char buf[1024], *trans = buf;
-         size_t trans_len = sizeof (buf);
+         mach_msg_type_number_t trans_len = sizeof (buf);
          error_t err = file_get_translator (node, &trans, &trans_len);
 
          switch (err)
diff --git a/utils/storeinfo.c b/utils/storeinfo.c
index c837f5d6..86ca4e4b 100644
--- a/utils/storeinfo.c
+++ b/utils/storeinfo.c
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <inttypes.h>
 #include <argp.h>
 #include <unistd.h>
 #include <sys/fcntl.h>
@@ -112,7 +113,7 @@ print_store (struct store *store, int level, unsigned what)
       if ((what & mask) == mask)
        {
          psep ();
-         printf ("%Ld", val);
+         printf ("%" PRIu64, val);
        }
     }
 
@@ -176,9 +177,10 @@ print_store (struct store *store, int level, unsigned what)
            putchar (',');
          if (store->runs[i].start < 0)
            /* A hole */
-           printf ("@+%Ld", store->runs[i].length);
+           printf ("@+%" PRIu64, store->runs[i].length);
          else
-           printf ("%Ld+%Ld", store->runs[i].start, store->runs[i].length);
+           printf ("%" PRIu64 "+%" PRIu64, store->runs[i].start,
+                   store->runs[i].length);
        }
     }
 
diff --git a/utils/vminfo.c b/utils/vminfo.c
index fcd6ca27..f33f282d 100644
--- a/utils/vminfo.c
+++ b/utils/vminfo.c
@@ -183,29 +183,29 @@ main (int argc, char **argv)
          if ((what & (W_ADDRS|W_SIZES)) == (W_ADDRS|W_SIZES))
            {
              if (hex)
-               printf ("          [%#lx] (hole)\n", addr - hole_addr);
+               printf ("          [%#zx] (hole)\n", addr - hole_addr);
              else
-               printf ("          [%lu] (hole)\n", addr - hole_addr);
+               printf ("          [%zu] (hole)\n", addr - hole_addr);
            }
          else if ((what & (W_ADDRS|W_SIZES)) == W_SIZES)
            {
              if (hex)
-               printf ("%#10lx (hole)\n", addr - hole_addr);
+               printf ("%#10zx (hole)\n", addr - hole_addr);
              else
-               printf ("%10lu (hole)\n", addr - hole_addr);
+               printf ("%10zu (hole)\n", addr - hole_addr);
            }
        }
 
       if ((what & (W_ADDRS|W_SIZES)) == (W_ADDRS|W_SIZES))
        if (hex)
-         printf ("%#10lx[%#zx]", addr, size);
+         printf ("%#10zx[%#zx]", addr, size);
        else
-         printf ("%10lu[%zd]", addr, size);
+         printf ("%10zu[%zd]", addr, size);
       else if ((what & (W_ADDRS|W_SIZES)) == W_ADDRS)
        if (hex)
-         printf ("%#10lx", addr);
+         printf ("%#10zx", addr);
        else
-         printf ("%10lu", addr);
+         printf ("%10zu", addr);
       else if ((what & (W_ADDRS|W_SIZES)) == W_SIZES)
        {
          if (hex)
@@ -223,13 +223,13 @@ main (int argc, char **argv)
          if (shared)
            printf (", shared");
          if (obj != MACH_PORT_NULL)
-           printf (", mem_obj=%lu", obj);
+           printf (", mem_obj=%u", obj);
          if (offs != 0)
            {
              if (hex)
-               printf (", offs=%#lx", offs);
+               printf (", offs=%#zx", offs);
              else
-               printf (", offs=%lu", offs);
+               printf (", offs=%zu", offs);
            }
          putchar (')');
        }
-- 
2.40.1




reply via email to

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