summaryrefslogtreecommitdiffstats
path: root/sys-utils/ipcmk.c
diff options
context:
space:
mode:
authorSami Kerola2011-08-28 13:09:03 +0200
committerSami Kerola2011-09-12 21:27:06 +0200
commitf5b0684e34124282c58e1d46971f22c71d196f16 (patch)
treed18f83d65ecb0082b1375e9f1ccc476e8abd14a8 /sys-utils/ipcmk.c
parentipcmk: add long options & fix usage() (diff)
downloadkernel-qcow2-util-linux-f5b0684e34124282c58e1d46971f22c71d196f16.tar.gz
kernel-qcow2-util-linux-f5b0684e34124282c58e1d46971f22c71d196f16.tar.xz
kernel-qcow2-util-linux-f5b0684e34124282c58e1d46971f22c71d196f16.zip
ipcmk: remove useless code
Checking same return value twice does not make command any better. Secondly the program_invocation_short_name is known to work, so global progname variable does not add anything extra. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/ipcmk.c')
-rw-r--r--sys-utils/ipcmk.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/sys-utils/ipcmk.c b/sys-utils/ipcmk.c
index 48fbc0e22..50ad79405 100644
--- a/sys-utils/ipcmk.c
+++ b/sys-utils/ipcmk.c
@@ -36,8 +36,6 @@
#include "nls.h"
#include "c.h"
-static const char *progname;
-
key_t createKey(void)
{
srandom( time( NULL ) );
@@ -46,44 +44,26 @@ key_t createKey(void)
int createShm(size_t size, int permission)
{
- int result = -1;
- int shmid;
key_t key = createKey();
-
- if (-1 != (shmid = shmget(key, size, permission | IPC_CREAT)))
- result = shmid;
-
- return result;
+ return shmget(key, size, permission | IPC_CREAT);
}
int createMsg(int permission)
{
- int result = -1;
- int msgid;
key_t key = createKey();
-
- if (-1 != (msgid = msgget(key, permission | IPC_CREAT)))
- result = msgid;
-
- return result;
+ return msgget(key, permission | IPC_CREAT);
}
int createSem(int nsems, int permission)
{
- int result = -1;
- int semid;
key_t key = createKey();
-
- if (-1 != (semid = semget(key, nsems, permission | IPC_CREAT)))
- result = semid;
-
- return result;
+ return semget(key, nsems, permission | IPC_CREAT);
}
static void __attribute__ ((__noreturn__)) usage(FILE * out)
{
fprintf(out, USAGE_HEADER);
- fprintf(out, _(" %s [options]\n"), progname);
+ fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
fprintf(out, USAGE_OPTIONS);
fputs(_(" -M, --shmem <size> create shared memory segment of size <size>\n"), out);
@@ -115,10 +95,6 @@ int main(int argc, char **argv)
{NULL, 0, NULL, 0}
};
- progname = program_invocation_short_name;
- if (!progname)
- progname = "ipcmk";
-
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);