diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-09-11 07:59:02 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-09-11 07:59:02 +0000 |
commit | 894554caf0e8f0874066ba938534c75be6330290 (patch) | |
tree | f23662dd0342dd524f9908b5d6fbc8fa33cc003d /usr.bin/ipcrm | |
parent | 5e316ba0cc6bc66eb75256d74843c567457d9d24 (diff) |
fix one warnx, -Wall the rest
Diffstat (limited to 'usr.bin/ipcrm')
-rw-r--r-- | usr.bin/ipcrm/ipcrm.c | 221 |
1 files changed, 118 insertions, 103 deletions
diff --git a/usr.bin/ipcrm/ipcrm.c b/usr.bin/ipcrm/ipcrm.c index 80662e7d3b3..b5dc75b3eb3 100644 --- a/usr.bin/ipcrm/ipcrm.c +++ b/usr.bin/ipcrm/ipcrm.c @@ -1,4 +1,5 @@ -/* * $OpenBSD: ipcrm.c,v 1.2 1996/06/26 05:34:35 deraadt Exp $*/ +/* $OpenBSD: ipcrm.c,v 1.3 1997/09/11 07:59:01 deraadt Exp $*/ + /* * Copyright (c) 1994 Adam Glass * All rights reserved. @@ -31,15 +32,17 @@ * */ -#include <stdio.h> -#include <unistd.h> -#include <err.h> -#include <signal.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <sys/sem.h> #include <sys/shm.h> +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <ctype.h> +#include <err.h> +#include <signal.h> #define IPC_TO_STR(x) (x == 'Q' ? "msq" : (x == 'M' ? "shm" : "sem")) #define IPC_TO_STRING(x) (x == 'Q' ? "message queue" : \ @@ -47,125 +50,137 @@ int signaled; -void usage() +void usage __P((void)); +int msgrm __P((key_t, int)); +int shmrm __P((key_t, int)); +int semrm __P((key_t, int)); +void not_configured __P((int)); + +void +usage() { fprintf(stderr, "usage: ipcrm [ [-q msqid] [-m shmid] [-s semid]\n"); fprintf(stderr, " [-Q msgkey] [-M shmkey] [-S semkey] ...]\n"); exit(1); } -int msgrm(key, id) - key_t key; - int id; +int +msgrm(key, id) + key_t key; + int id; { - if (key) { - id = msgget(key, 0); - if (id == -1) - return -1; - } - return msgctl(id, IPC_RMID, NULL); + if (key) { + id = msgget(key, 0); + if (id == -1) + return (-1); + } + return (msgctl(id, IPC_RMID, NULL)); } -int shmrm(key, id) - key_t key; - int id; +int +shmrm(key, id) + key_t key; + int id; { - if (key) { - id = shmget(key, 0, 0); - if (id == -1) - return -1; - } - return shmctl(id, IPC_RMID, NULL); + if (key) { + id = shmget(key, 0, 0); + if (id == -1) + return (-1); + } + return (shmctl(id, IPC_RMID, NULL)); } -int semrm(key, id) - key_t key; - int id; +int +semrm(key, id) + key_t key; + int id; { - union semun arg; + union semun arg; - if (key) { - id = semget(key, 0, 0); - if (id == -1) - return -1; - } - return semctl(id, 0, IPC_RMID, arg); + if (key) { + id = semget(key, 0, 0); + if (id == -1) + return (-1); + } + return (semctl(id, 0, IPC_RMID, arg)); } -void not_configured() +void +not_configured(sig) + int sig; { - signaled++; + signaled++; } - -int main(argc, argv) - int argc; - char *argv[]; +int +main(argc, argv) + int argc; + char *argv[]; { - int c, result, errflg, target_id; - key_t target_key; - - errflg = 0; - signal(SIGSYS, not_configured); - while ((c = getopt(argc, argv, ":q:m:s:Q:M:S:")) != -1) { + int c, result, errflg, target_id; + key_t target_key; - signaled = 0; - switch (c) { - case 'q': - case 'm': - case 's': - target_id = atoi(optarg); - if (c == 'q') - result = msgrm(0, target_id); - else if (c == 'm') - result = shmrm(0, target_id); - else - result = semrm(0, target_id); - if (result < 0) { - errflg++; - if (!signaled) - warn("%sid(%d): ", IPC_TO_STR(toupper(c)), target_id); - else - warnx("%ss are not configured in the running kernel", - IPC_TO_STRING(toupper(c))); - } - break; - case 'Q': - case 'M': - case 'S': - target_key = atol(optarg); - if (target_key == IPC_PRIVATE) { - warnx("can't remove private %ss", IPC_TO_STRING(c)); - continue; - } - if (c == 'Q') - result = msgrm(target_key, 0); - else if (c == 'M') - result = shmrm(target_key, 0); - else - result = semrm(target_key, 0); - if (result < 0) { - errflg++; - if (!signaled) - warn("%key(%ld): ", IPC_TO_STR(c), target_key); - else - warnx("%ss are not configured in the running kernel", - IPC_TO_STRING(c)); - } - break; - case ':': - fprintf(stderr, "option -%c requires an argument\n", optopt); - usage(); - case '?': - fprintf(stderr, "unrecognized option: -%c\n", optopt); - usage(); + errflg = 0; + signal(SIGSYS, not_configured); + while ((c = getopt(argc, argv, ":q:m:s:Q:M:S:")) != -1) { + signaled = 0; + switch (c) { + case 'q': + case 'm': + case 's': + target_id = atoi(optarg); + if (c == 'q') + result = msgrm(0, target_id); + else if (c == 'm') + result = shmrm(0, target_id); + else + result = semrm(0, target_id); + if (result < 0) { + errflg++; + if (!signaled) + warn("%sid(%d): ", + IPC_TO_STR(toupper(c)), target_id); + else + warnx("%ss are not configured in the running kernel", + IPC_TO_STRING(toupper(c))); + } + break; + case 'Q': + case 'M': + case 'S': + target_key = atol(optarg); + if (target_key == IPC_PRIVATE) { + warnx("can't remove private %ss", IPC_TO_STRING(c)); + continue; + } + if (c == 'Q') + result = msgrm(target_key, 0); + else if (c == 'M') + result = shmrm(target_key, 0); + else + result = semrm(target_key, 0); + if (result < 0) { + errflg++; + if (!signaled) + warn("%skey(%ld): ", IPC_TO_STR(c), + target_key); + else + warnx("%ss are not configured in the running kernel", + IPC_TO_STRING(c)); + } + break; + case ':': + fprintf(stderr, "option -%c requires an argument\n", optopt); + usage(); + default: + fprintf(stderr, "unrecognized option: -%c\n", optopt); + usage(); + } } - } - if (optind != argc) { - fprintf(stderr, "unknown argument: %s\n", argv[optind]); - usage(); - } - exit(errflg); + if (optind != argc) { + fprintf(stderr, "unknown argument: %s\n", argv[optind]); + usage(); + } + exit(errflg); } - |