public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED() returned true
@ 2016-02-24 10:19 Han Pingtian
  2016-02-24 11:03 ` Jan Stancek
  0 siblings, 1 reply; 5+ messages in thread
From: Han Pingtian @ 2016-02-24 10:19 UTC (permalink / raw)
  To: ltp

Only when WIFEXITED() returned true that WEXITSTATUS() can return a
meanful result. So we should check WIFEXITED() first.

Signed-off-by: Han Pingtian <hanpt@linux.vnet.ibm.com>
---
 testcases/kernel/mem/lib/mem.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index cedcf32..8327998 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -150,12 +150,16 @@ void oom(int testcase, int lite, int retcode, int allow_sigkill)
 				WTERMSIG(status),
 				tst_strsig(WTERMSIG(status)));
 		}
-	} else	if (WIFEXITED(status) && WEXITSTATUS(status) == retcode) {
-		tst_resm(TPASS, "victim retcode: (%d) %s",
+	} else if (WIFEXITED(status)) {
+		if (WEXITSTATUS(status) == retcode) {
+			tst_resm(TPASS, "victim retcode: (%d) %s",
 				retcode, strerror(retcode));
-	} else {
-		tst_resm(TFAIL, "victim unexpectedly ended with retcode: %d, "
+		} else {
+			tst_resm(TFAIL, "victim unexpectedly ended with retcode: %d, "
 				"expected: %d", WEXITSTATUS(status), retcode);
+		}
+	} else {
+		tst_resm(TFAIL, "victim unexpectedly ended");
 	}
 }
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-26  2:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-24 10:19 [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED() returned true Han Pingtian
2016-02-24 11:03 ` Jan Stancek
2016-02-25  1:18   ` Han Pingtian
2016-02-25  7:46     ` Jan Stancek
2016-02-26  2:25       ` Han Pingtian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox