svn commit: r281501 - head/usr.bin/ipcs
Eitan Adler
eadler at FreeBSD.org
Mon Apr 13 19:58:13 UTC 2015
Author: eadler
Date: Mon Apr 13 19:58:11 2015
New Revision: 281501
URL: https://svnweb.freebsd.org/changeset/base/281501
Log:
ipcs: fix warnings (WARNS=1 -> WARNS=6)
- fix shadow warnings
- change type from off_t to size_t which is more correct and avoids
signed/unsigned compare
- use new initializer format to avoid "missing values" warning
Reviewed by: jhb
Modified:
head/usr.bin/ipcs/Makefile
head/usr.bin/ipcs/ipc.c
head/usr.bin/ipcs/ipc.h
head/usr.bin/ipcs/ipcs.c
Modified: head/usr.bin/ipcs/Makefile
==============================================================================
--- head/usr.bin/ipcs/Makefile Mon Apr 13 19:46:30 2015 (r281500)
+++ head/usr.bin/ipcs/Makefile Mon Apr 13 19:58:11 2015 (r281501)
@@ -4,6 +4,4 @@ PROG= ipcs
SRCS= ipcs.c ipc.c
LIBADD= kvm
-WARNS?= 1
-
.include <bsd.prog.mk>
Modified: head/usr.bin/ipcs/ipc.c
==============================================================================
--- head/usr.bin/ipcs/ipc.c Mon Apr 13 19:46:30 2015 (r281500)
+++ head/usr.bin/ipcs/ipc.c Mon Apr 13 19:58:11 2015 (r281501)
@@ -58,13 +58,13 @@ struct shmid_kernel *shmsegs;
void kget(int idx, void *addr, size_t size);
struct nlist symbols[] = {
- {"sema"},
- {"seminfo"},
- {"msginfo"},
- {"msqids"},
- {"shminfo"},
- {"shmsegs"},
- {NULL}
+ { .n_name = "sema" },
+ { .n_name = "seminfo" },
+ { .n_name = "msginfo" },
+ { .n_name = "msqids" },
+ { .n_name = "shminfo" },
+ { .n_name = "shmsegs" },
+ { .n_name = NULL }
};
#define SHMINFO_XVEC X(shmmax, sizeof(u_long)) \
@@ -92,13 +92,13 @@ struct nlist symbols[] = {
#define X(a, b) { "kern.ipc." #a, offsetof(TYPEC, a), (b) },
#define TYPEC struct shminfo
-struct scgs_vector shminfo_scgsv[] = { SHMINFO_XVEC { NULL } };
+static struct scgs_vector shminfo_scgsv[] = { SHMINFO_XVEC { .sysctl=NULL } };
#undef TYPEC
#define TYPEC struct seminfo
-struct scgs_vector seminfo_scgsv[] = { SEMINFO_XVEC { NULL } };
+static struct scgs_vector seminfo_scgsv[] = { SEMINFO_XVEC { .sysctl=NULL } };
#undef TYPEC
#define TYPEC struct msginfo
-struct scgs_vector msginfo_scgsv[] = { MSGINFO_XVEC { NULL } };
+static struct scgs_vector msginfo_scgsv[] = { MSGINFO_XVEC { .sysctl=NULL } };
#undef TYPEC
#undef X
Modified: head/usr.bin/ipcs/ipc.h
==============================================================================
--- head/usr.bin/ipcs/ipc.h Mon Apr 13 19:46:30 2015 (r281500)
+++ head/usr.bin/ipcs/ipc.h Mon Apr 13 19:58:11 2015 (r281501)
@@ -52,7 +52,7 @@
/* SysCtlGatherStruct structure. */
struct scgs_vector {
const char *sysctl;
- off_t offset;
+ size_t offset;
size_t size;
};
Modified: head/usr.bin/ipcs/ipcs.c
==============================================================================
--- head/usr.bin/ipcs/ipcs.c Mon Apr 13 19:46:30 2015 (r281500)
+++ head/usr.bin/ipcs/ipcs.c Mon Apr 13 19:58:11 2015 (r281501)
@@ -112,6 +112,7 @@ main(int argc, char *argv[])
char *core = NULL, *user = NULL, *namelist = NULL;
char kvmoferr[_POSIX2_LINE_MAX]; /* Error buf for kvm_openfiles. */
int i;
+ u_long shmidx;
uid_t uid = 0;
while ((i = getopt(argc, argv, "MmQqSsabC:cN:optTu:y")) != -1)
@@ -247,13 +248,13 @@ main(int argc, char *argv[])
print_kshmheader(option);
- for (i = 0; i < shminfo.shmmni; i += 1) {
- if (kxshmids[i].u.shm_perm.mode & 0x0800) {
+ for (shmidx = 0; shmidx < shminfo.shmmni; shmidx += 1) {
+ if (kxshmids[shmidx].u.shm_perm.mode & 0x0800) {
if (user &&
- uid != kxshmids[i].u.shm_perm.uid)
+ uid != kxshmids[shmidx].u.shm_perm.uid)
continue;
- print_kshmptr(i, option, &kxshmids[i]);
+ print_kshmptr(shmidx, option, &kxshmids[shmidx]);
}
}
printf("\n");
@@ -309,22 +310,22 @@ main(int argc, char *argv[])
}
void
-print_kmsqtotal(struct msginfo msginfo)
+print_kmsqtotal(struct msginfo local_msginfo)
{
printf("msginfo:\n");
printf("\tmsgmax: %12d\t(max characters in a message)\n",
- msginfo.msgmax);
+ local_msginfo.msgmax);
printf("\tmsgmni: %12d\t(# of message queues)\n",
- msginfo.msgmni);
+ local_msginfo.msgmni);
printf("\tmsgmnb: %12d\t(max characters in a message queue)\n",
- msginfo.msgmnb);
+ local_msginfo.msgmnb);
printf("\tmsgtql: %12d\t(max # of messages in system)\n",
- msginfo.msgtql);
+ local_msginfo.msgtql);
printf("\tmsgssz: %12d\t(size of a message segment)\n",
- msginfo.msgssz);
+ local_msginfo.msgssz);
printf("\tmsgseg: %12d\t(# of message segments in system)\n\n",
- msginfo.msgseg);
+ local_msginfo.msgseg);
}
void print_kmsqheader(int option)
@@ -390,20 +391,20 @@ print_kmsqptr(int i, int option, struct
}
void
-print_kshmtotal(struct shminfo shminfo)
+print_kshmtotal(struct shminfo local_shminfo)
{
printf("shminfo:\n");
printf("\tshmmax: %12lu\t(max shared memory segment size)\n",
- shminfo.shmmax);
+ local_shminfo.shmmax);
printf("\tshmmin: %12lu\t(min shared memory segment size)\n",
- shminfo.shmmin);
+ local_shminfo.shmmin);
printf("\tshmmni: %12lu\t(max number of shared memory identifiers)\n",
- shminfo.shmmni);
+ local_shminfo.shmmni);
printf("\tshmseg: %12lu\t(max shared memory segments per process)\n",
- shminfo.shmseg);
+ local_shminfo.shmseg);
printf("\tshmall: %12lu\t(max amount of shared memory in pages)\n\n",
- shminfo.shmall);
+ local_shminfo.shmall);
}
void
@@ -470,28 +471,28 @@ print_kshmptr(int i, int option, struct
}
void
-print_ksemtotal(struct seminfo seminfo)
+print_ksemtotal(struct seminfo local_seminfo)
{
printf("seminfo:\n");
printf("\tsemmni: %12d\t(# of semaphore identifiers)\n",
- seminfo.semmni);
+ local_seminfo.semmni);
printf("\tsemmns: %12d\t(# of semaphores in system)\n",
- seminfo.semmns);
+ local_seminfo.semmns);
printf("\tsemmnu: %12d\t(# of undo structures in system)\n",
- seminfo.semmnu);
+ local_seminfo.semmnu);
printf("\tsemmsl: %12d\t(max # of semaphores per id)\n",
- seminfo.semmsl);
+ local_seminfo.semmsl);
printf("\tsemopm: %12d\t(max # of operations per semop call)\n",
- seminfo.semopm);
+ local_seminfo.semopm);
printf("\tsemume: %12d\t(max # of undo entries per process)\n",
- seminfo.semume);
+ local_seminfo.semume);
printf("\tsemusz: %12d\t(size in bytes of undo structure)\n",
- seminfo.semusz);
+ local_seminfo.semusz);
printf("\tsemvmx: %12d\t(semaphore maximum value)\n",
- seminfo.semvmx);
+ local_seminfo.semvmx);
printf("\tsemaem: %12d\t(adjust on exit max value)\n\n",
- seminfo.semaem);
+ local_seminfo.semaem);
}
void
More information about the svn-src-head
mailing list