From f5b0684e34124282c58e1d46971f22c71d196f16 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 28 Aug 2011 13:09:03 +0200 Subject: 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 --- sys-utils/ipcmk.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'sys-utils/ipcmk.c') 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 create shared memory segment of 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); -- cgit v1.2.3-55-g7522