From: Sami Kerola Date: Sun, 28 Aug 2011 11:09:03 +0000 (+0200) Subject: ipcmk: remove useless code X-Git-Tag: v2.21-rc1~402^2~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f5b0684e34124282c58e1d46971f22c71d196f16;p=thirdparty%2Futil-linux.git 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 --- diff --git a/sys-utils/ipcmk.c b/sys-utils/ipcmk.c index 48fbc0e228..50ad79405a 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);