Skip to contentSkip to conversation

Fix shmat() wrong return value test method

PATCH New Dongliang Ma 1 participant 1 message Jul 8, 2014 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix shmat() wrong return value test method

From: Dongliang Ma <mdl13412 at gmail.com>

This patch fixed the invalid shmat() return value test method.

Signed-off-by Dongliang Ma <mdl13412 at gmail.com>

---
usr/log.c | 6 +++---

1 files changed, 3 insertions(+), 3 deletions(-)

---

usr/log.c +3 -3
index 2f0c4d4..24a3af9 100644
@@ -61,7 +61,7 @@ static int logarea_init (int size)
 	}
 
 	la = shmat(shmid, NULL, 0);
-	if (!la) {
+	if (la == ((void *) -1)) {
 		syslog(LOG_ERR, "shmat logarea failed %d", errno);
 		return 1;
 	}
@@ -79,7 +79,7 @@ static int logarea_init (int size)
 	}
 
 	la->start = shmat(shmid, NULL, 0);
-	if (!la->start) {
+	if (la->start == ((void *) -1)) {
 		syslog(LOG_ERR, "shmat msg failed %d", errno);
 		shmdt(la);
 		return 1;
@@ -101,7 +101,7 @@ static int logarea_init (int size)
 		return 1;
 	}
 	la->buff = shmat(shmid, NULL, 0);
-	if (!la->buff) {
+	if (la->buff == ((void *) -1)) {
 		syslog(LOG_ERR, "shmat logmsgfailed %d", errno);
 		shmdt(la->start);
 		shmdt(la);