This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix argument passing in sysvipc/test-sysvsem


The command IPC_STAT of semctl() expects an union semun in its fourth
argument instead of struct semid_ds *.
This can cause failures on ppc.

Tested on ppc.

2016-12-30  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>

	* sysvipc/test-sysvsem.c: Define union semun.
	(do_test): Pass union semun to semctl() instead of struct
	semid_ds *.
---
 sysvipc/test-sysvsem.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/sysvipc/test-sysvsem.c b/sysvipc/test-sysvsem.c
index fd9db4f..6cc0c46 100644
--- a/sysvipc/test-sysvsem.c
+++ b/sysvipc/test-sysvsem.c
@@ -28,6 +28,17 @@
 #include <support/check.h>
 #include <support/temp_file.h>
 
+/* Confirm if sys/sem.h defines semun.  */
+#ifdef _SEM_SEMUN_UNDEFINED
+union semun
+{
+  int val;
+  struct semid_ds *buf;
+    unsigned short int *array;
+  struct seminfo *__buf;
+};
+#endif
+
 /* These are for the temporary file we generate.  */
 static char *name;
 static int semid;
@@ -74,7 +85,10 @@ do_test (void)
 
   /* Get semaphore kernel information and do some sanity checks.  */
   struct semid_ds seminfo;
-  if (semctl (semid, 0, IPC_STAT, &seminfo) == -1)
+
+  union semun semarg;
+  semarg.buf = &seminfo;
+  if (semctl (semid, 0, IPC_STAT, semarg) == -1)
     FAIL_EXIT1 ("semctl with IPC_STAT failed (errno=%d)", errno);
 
   if (seminfo.sem_perm.__key != key)
-- 
2.1.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]