All of lore.kernel.org
 help / color / mirror / Atom feed
* [CRIU][PATCH 7/7] zdtm/static/sem: Use "union semun" instead of int
@ 2017-06-28 16:12 Michael Holzheu
  0 siblings, 0 replies; only message in thread
From: Michael Holzheu @ 2017-06-28 16:12 UTC (permalink / raw)
  To: linux-s390

From: Alice Frosi <alice@inux.vnet.ibm.com>

Use "union semun" for semctl() to make testcase also work on s390x.

Signed-off-by: Alice Frosi <alice@linux.vnet.ibm.com>
---
 test/zdtm/static/sem.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/test/zdtm/static/sem.c b/test/zdtm/static/sem.c
index 6e459a8..1db8f00 100644
--- a/test/zdtm/static/sem.c
+++ b/test/zdtm/static/sem.c
@@ -110,7 +110,13 @@ int main(int argc, char **argv)
 {
 	int id, key;
 	int i;
-	int val[NSEMS];
+	/* See man semctl */
+	union semun {
+		int		val;
+		struct		semid_ds *buf;
+		unsigned short	*array;
+		struct seminfo	*__buf;
+	} val[NSEMS];
 	int ret, fail_count = 0;
 
 	test_init(argc, argv);
@@ -129,7 +135,7 @@ int main(int argc, char **argv)
 	}
 
 	for (i = 0; i < NSEMS; i++) {
-		val[i] = lrand48() & 0x7;
+		val[i].val = lrand48() & 0x7;
 
 		if (semctl(id, i, SETVAL, val[i]) == -1) {
 			fail_count++;
@@ -142,7 +148,7 @@ int main(int argc, char **argv)
 	test_waitsig();
 
 	for (i = 0; i < NSEMS; i++) {
-		ret = check_sem_by_id(id, i, val[i]);
+		ret = check_sem_by_id(id, i, val[i].val);
 		if (ret < 0) {
 			fail_count++;
 			fail("Check sem %d by id failed", i);
@@ -155,14 +161,14 @@ int main(int argc, char **argv)
 			goto out_destroy;
 		}
 
-		val[i] = semctl(id, 0, GETVAL);
-		if (val[i] < 0) {
+		val[i].val = semctl(id, 0, GETVAL);
+		if (val[i].val < 0) {
 			fail("Failed to get sem %d value", i);
 			fail_count++;
 			goto out_destroy;
 		}
-		if (val[i] != 0) {
-			fail("Non-zero sem %d value: %d", i, val[i]);
+		if (val[i].val != 0) {
+			fail("Non-zero sem %d value: %d", i, val[i].val);
 			fail_count++;
 		}
 	}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-28 16:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28 16:12 [CRIU][PATCH 7/7] zdtm/static/sem: Use "union semun" instead of int Michael Holzheu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.