Skip to contentSkip to conversation

tests/tcg/multiarch/linux-test: Fix error check for shmat

PATCH In review Richard Henderson 2 participants 3 messages Jul 9, 2018 – Jan 29, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/tcg/multiarch/linux-test: Fix error check for shmat

The error indicator for this syscall is -1, not 0.

---
 tests/tcg/multiarch/linux-test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tests/tcg/multiarch/linux-test.c +2 -1
index e80eccc0ce..6d2c02c5c0 100644
@@ -503,8 +503,9 @@ static void test_shm(void)
 
     shmid = chk_error(shmget(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | 0777));
     ptr = shmat(shmid, NULL, 0);
-    if (!ptr)
+    if (ptr == (void *)-1) {
         error("shmat");
+    }
 
     memset(ptr, 0, SHM_SIZE);
 
Signature · 1 line
2.17.1
#1 lore raw

Ping.

Quoted 23 lines · Richard Henderson

The error indicator for this syscall is -1, not 0.

---
 tests/tcg/multiarch/linux-test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tests/tcg/multiarch/linux-test.c +2 -1
index e80eccc0ce..6d2c02c5c0 100644
@@ -503,8 +503,9 @@ static void test_shm(void)
 
     shmid = chk_error(shmget(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | 0777));
     ptr = shmat(shmid, NULL, 0);
-    if (!ptr)
+    if (ptr == (void *)-1) {
         error("shmat");
+    }
 
     memset(ptr, 0, SHM_SIZE);