]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
ipcmk: remove useless code
authorSami Kerola <kerolasa@iki.fi>
Sun, 28 Aug 2011 11:09:03 +0000 (13:09 +0200)
committerSami Kerola <kerolasa@iki.fi>
Mon, 12 Sep 2011 19:27:06 +0000 (21:27 +0200)
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>
sys-utils/ipcmk.c

index 48fbc0e228712c1070cf43cd355c7a5ba800c2bc..50ad79405a645514f3ffcea4f8ad30b28004d5d7 100644 (file)
@@ -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);