]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
ipcs: fix compiler warnings, use 64bit time
authorKarel Zak <kzak@redhat.com>
Thu, 20 Dec 2012 18:52:16 +0000 (19:52 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 20 Dec 2012 18:52:16 +0000 (19:52 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/ipcs.c
sys-utils/ipcutils.c
sys-utils/ipcutils.h

index 4aecc4134e1f68ff67720e6d86469087ce2bf9ae..4422162eee8fba547aaa338867c477808592e2a7 100644 (file)
@@ -44,6 +44,9 @@ static void print_sem (int id);
 static void do_msg (char format, int unit);
 static void print_msg (int id, int unit);
 
+/* we read time as int64_t from /proc, so cast... */
+#define xctime(_x)     ctime((time_t *) (_x))
+
 static void __attribute__ ((__noreturn__)) usage(FILE * out)
 {
        fprintf(out, USAGE_HEADER);
@@ -291,11 +294,11 @@ static void do_shm (char format, int unit)
                                printf ("%-10d %-10u", shmdsp->shm_perm.id, shmdsp->shm_perm.uid);
                        /* ctime uses static buffer: use separate calls */
                        printf(" %-20.16s", shmdsp->shm_atim
-                              ? ctime(&shmdsp->shm_atim) + 4 : _("Not set"));
+                              ? xctime(&shmdsp->shm_atim) + 4 : _("Not set"));
                        printf(" %-20.16s", shmdsp->shm_dtim
-                              ? ctime(&shmdsp->shm_dtim) + 4 : _("Not set"));
+                              ? xctime(&shmdsp->shm_dtim) + 4 : _("Not set"));
                        printf(" %-20.16s\n", shmdsp->shm_ctim
-                              ? ctime(&shmdsp->shm_ctim) + 4 : _("Not set"));
+                              ? xctime(&shmdsp->shm_ctim) + 4 : _("Not set"));
                        break;
                case PID:
                        if (pw)
@@ -319,7 +322,7 @@ static void do_shm (char format, int unit)
                        else
                                ipc_print_size(unit, NULL, shmdsp->shm_segsz, NULL, -10);
 
-                       printf (" %-10ld %-6s %-6s\n",
+                       printf (" %-10ju %-6s %-6s\n",
                                shmdsp->shm_nattch,
                                shmdsp->shm_perm.mode & SHM_DEST ? _("dest") : " ",
                                shmdsp->shm_perm.mode & SHM_LOCKED ? _("locked") : " ");
@@ -408,9 +411,9 @@ static void do_sem (char format)
                        else
                                printf ("%-8d %-10u", semdsp->sem_perm.id, semdsp->sem_perm.uid);
                        printf ("  %-26.24s", semdsp->sem_otime
-                               ? ctime(&semdsp->sem_otime) : _("Not set"));
+                               ? xctime(&semdsp->sem_otime) : _("Not set"));
                        printf (" %-26.24s\n", semdsp->sem_ctime
-                               ? ctime(&semdsp->sem_ctime) : _("Not set"));
+                               ? xctime( &semdsp->sem_ctime) : _("Not set"));
                        break;
                case PID:
                        break;
@@ -421,7 +424,7 @@ static void do_sem (char format)
                                printf ("%-10d %-10.10s", semdsp->sem_perm.id, pw->pw_name);
                        else
                                printf ("%-10d %-10u", semdsp->sem_perm.id, semdsp->sem_perm.uid);
-                       printf (" %-10o %-10ld\n",
+                       printf (" %-10o %-10ju\n",
                                semdsp->sem_perm.mode & 0777,
                                semdsp->sem_nsems);
                        break;
@@ -513,11 +516,11 @@ static void do_msg (char format, int unit)
                        else
                                printf ("%-8d %-10u", msgdsp->msg_perm.id, msgdsp->msg_perm.uid);
                        printf (" %-20.16s", msgdsp->q_stime
-                               ? ctime(&msgdsp->q_stime) + 4 : _("Not set"));
+                               ? xctime(&msgdsp->q_stime) + 4 : _("Not set"));
                        printf (" %-20.16s", msgdsp->q_rtime
-                               ? ctime(&msgdsp->q_rtime) + 4 : _("Not set"));
+                               ? xctime(&msgdsp->q_rtime) + 4 : _("Not set"));
                        printf (" %-20.16s\n", msgdsp->q_ctime
-                               ? ctime(&msgdsp->q_ctime) + 4 : _("Not set"));
+                               ? xctime(&msgdsp->q_ctime) + 4 : _("Not set"));
                        break;
                case PID:
                        if (pw)
@@ -541,7 +544,7 @@ static void do_msg (char format, int unit)
                        else
                                ipc_print_size(unit, NULL, msgdsp->q_cbytes, NULL, -12);
 
-                       printf (" %-12ld\n", msgdsp->q_qnum);
+                       printf (" %-12ju\n", msgdsp->q_qnum);
                        break;
                }
        }
@@ -571,10 +574,10 @@ static void print_shm(int shmid, int unit)
               shmdata->shm_lprid, shmdata->shm_cprid,
               shmdata->shm_nattch);
        printf(_("att_time=%-26.24s\n"),
-              shmdata->shm_atim ? ctime(&(shmdata->shm_atim)) : _("Not set"));
+              shmdata->shm_atim ? xctime(&(shmdata->shm_atim)) : _("Not set"));
        printf(_("det_time=%-26.24s\n"),
-              shmdata->shm_dtim ? ctime(&shmdata->shm_dtim) : _("Not set"));
-       printf(_("change_time=%-26.24s\n"), ctime(&shmdata->shm_ctim));
+              shmdata->shm_dtim ? xctime(&shmdata->shm_dtim) : _("Not set"));
+       printf(_("change_time=%-26.24s\n"), xctime(&shmdata->shm_ctim));
        printf("\n");
 
        ipc_shm_free_info(shmdata);
@@ -602,11 +605,11 @@ void print_msg(int msgid, int unit)
               msgdata->q_qnum,
               msgdata->q_lspid, msgdata->q_lrpid);
        printf(_("send_time=%-26.24s\n"),
-              msgdata->q_stime ? ctime(&msgdata->q_stime) : _("Not set"));
+              msgdata->q_stime ? xctime(&msgdata->q_stime) : _("Not set"));
        printf(_("rcv_time=%-26.24s\n"),
-              msgdata->q_rtime ? ctime(&msgdata->q_rtime) : _("Not set"));
+              msgdata->q_rtime ? xctime(&msgdata->q_rtime) : _("Not set"));
        printf(_("change_time=%-26.24s\n"),
-              msgdata->q_ctime ? ctime(&msgdata->q_ctime) : _("Not set"));
+              msgdata->q_ctime ? xctime(&msgdata->q_ctime) : _("Not set"));
        printf("\n");
 
        ipc_msg_free_info(msgdata);
@@ -628,10 +631,10 @@ static void print_sem(int semid)
               semdata->sem_perm.cuid, semdata->sem_perm.cgid);
        printf(_("mode=%#o, access_perms=%#o\n"),
               semdata->sem_perm.mode, semdata->sem_perm.mode & 0777);
-       printf(_("nsems = %ld\n"), semdata->sem_nsems);
+       printf(_("nsems = %ju\n"), semdata->sem_nsems);
        printf(_("otime = %-26.24s\n"),
-              semdata->sem_otime ? ctime(&semdata->sem_otime) : _("Not set"));
-       printf(_("ctime = %-26.24s\n"), ctime(&semdata->sem_ctime));
+              semdata->sem_otime ? xctime(&semdata->sem_otime) : _("Not set"));
+       printf(_("ctime = %-26.24s\n"), xctime(&semdata->sem_ctime));
 
        printf("%-10s %-10s %-10s %-10s %-10s\n",
               _("semnum"), _("value"), _("ncount"), _("zcount"), _("pid"));
index d81ca20639ff3a478711b5cbaf7a5dbd25a8eb16..0cac49ef495bfc70055c1faebd75fb46de3e9365 100644 (file)
@@ -112,7 +112,7 @@ int ipc_shm_get_info(int id, struct shm_data **shmds)
        while (feof(f) == 0) {
                if (fscanf(f,
                          "%d %d  %o %"SCNu64 " %u %u  "
-                         "%"SCNu64 " %u %u %u %u %"SCNu64 " %"SCNu64 " %"SCNu64
+                         "%"SCNu64 " %u %u %u %u %"SCNi64 " %"SCNi64 " %"SCNi64
                          " %"SCNu64 " %"SCNu64 "\n",
                           &p->shm_perm.key,
                           &p->shm_perm.id,
@@ -263,7 +263,8 @@ int ipc_sem_get_info(int id, struct sem_data **semds)
 
        while (feof(f) == 0) {
                if (fscanf(f,
-                          "%d %d  %o %" SCNu64 " %u %u %u %u %" SCNu64 " %" SCNu64 "\n",
+                          "%d %d  %o %" SCNu64 " %u %u %u %u %"
+                           SCNi64 " %" SCNi64 "\n",
                           &p->sem_perm.key,
                           &p->sem_perm.id,
                           &p->sem_perm.mode,
@@ -376,7 +377,8 @@ int ipc_msg_get_info(int id, struct msg_data **msgds)
 
        while (feof(f) == 0) {
                if (fscanf(f,
-                          "%d %d  %o  %" SCNu64 " %" SCNu64 " %u %u %u %u %u %u %" SCNu64 " %" SCNu64 " %" SCNu64 "\n",
+                          "%d %d  %o  %" SCNu64 " %" SCNu64
+                          " %u %u %u %u %u %u %" SCNi64 " %" SCNi64 " %" SCNi64 "\n",
                           &p->msg_perm.key,
                           &p->msg_perm.id,
                           &p->msg_perm.mode,
index 6383124ff1a5e35a8df637d9162dda3b69a21e60..d2e5972dd02a183ff6f9be97af84dcf85652903a 100644 (file)
@@ -127,9 +127,9 @@ struct shm_data {
 
        uint64_t        shm_nattch;
        uint64_t        shm_segsz;
-       time_t          shm_atim;
-       time_t          shm_dtim;
-       time_t          shm_ctim;
+       int64_t         shm_atim;       /* __kernel_time_t is signed long */
+       int64_t         shm_dtim;
+       int64_t         shm_ctim;
        pid_t           shm_cprid;
        pid_t           shm_lprid;
        uint64_t        shm_rss;
@@ -152,8 +152,8 @@ struct sem_elem {
 struct sem_data {
        struct ipc_stat sem_perm;
 
-       time_t          sem_ctime;
-       time_t          sem_otime;
+       int64_t         sem_ctime;
+       int64_t         sem_otime;
        uint64_t        sem_nsems;
 
        struct sem_elem *elements;
@@ -168,9 +168,9 @@ extern void ipc_sem_free_info(struct sem_data *semds);
 struct msg_data {
        struct ipc_stat msg_perm;
 
-       time_t          q_stime;
-       time_t          q_rtime;
-       time_t          q_ctime;
+       int64_t         q_stime;
+       int64_t         q_rtime;
+       int64_t         q_ctime;
        uint64_t        q_cbytes;
        uint64_t        q_qnum;
        uint64_t        q_qbytes;