]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(__old_semctl, __new_semctl): Only use va_arg if the argument will be used.
authorUlrich Drepper <drepper@redhat.com>
Tue, 16 Jul 2002 00:32:45 +0000 (00:32 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 16 Jul 2002 00:32:45 +0000 (00:32 +0000)
sysdeps/unix/sysv/linux/semctl.c

index f2d71ed68479cfbbd26627866ab0bbf544618b9b..a3d9e588a00a06bfb0da748c5653e4097c4d0d96 100644 (file)
@@ -69,8 +69,23 @@ __old_semctl (int semid, int semnum, int cmd, ...)
 
   va_start (ap, cmd);
 
-  /* Get the argument.  */
-  arg = va_arg (ap, union semun);
+  /* Get the argument only if required.  */
+  arg.buf = NULL;
+  switch (cmd)
+    {
+    case SETVAL:        /* arg.val */
+    case GETALL:        /* arg.array */
+    case SETALL:
+    case IPC_STAT:      /* arg.buf */
+    case IPC_SET:
+    case SEM_STAT:
+    case IPC_INFO:      /* arg.__buf */
+    case SEM_INFO:
+      va_start (ap, cmd);
+      arg = va_arg (ap, union semun);
+      va_end (ap);
+      break;
+    }
 
   va_end (ap);
 
@@ -88,8 +103,23 @@ __new_semctl (int semid, int semnum, int cmd, ...)
 
   va_start (ap, cmd);
 
-  /* Get the argument.  */
-  arg = va_arg (ap, union semun);
+  /* Get the argument only if required.  */
+  arg.buf = NULL;
+  switch (cmd)
+    {
+    case SETVAL:        /* arg.val */
+    case GETALL:        /* arg.array */
+    case SETALL:
+    case IPC_STAT:      /* arg.buf */
+    case IPC_SET:
+    case SEM_STAT:
+    case IPC_INFO:      /* arg.__buf */
+    case SEM_INFO:
+      va_start (ap, cmd);
+      arg = va_arg (ap, union semun);
+      va_end (ap);
+      break;
+    }
 
   va_end (ap);