public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] hugemmap/hugemmap05.c: fix warnings in cleanup()
@ 2017-08-31  2:59 Xiao Yang
  2017-09-05  8:13 ` Li Wang
  2017-09-06 14:02 ` Cyril Hrubis
  0 siblings, 2 replies; 3+ messages in thread
From: Xiao Yang @ 2017-08-31  2:59 UTC (permalink / raw)
  To: ltp

1) We only destroy the shared memory segment if it was still created.
2) We only close and delete the test file if it was still created and opened.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c
index 90389dd..c73a975 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c
@@ -178,9 +178,10 @@ static void test_overcommit(void)
 
 static void cleanup(void)
 {
-	if (opt_shmid) {
+	if (opt_shmid && shmid != -1)
 		SAFE_SHMCTL(shmid, IPC_RMID, NULL);
-	} else {
+
+	if (!opt_shmid && fd != -1) {
 		SAFE_CLOSE(fd);
 		SAFE_UNLINK(TEST_FILE);
 	}
-- 
1.8.3.1




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

end of thread, other threads:[~2017-09-06 14:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-31  2:59 [LTP] [PATCH] hugemmap/hugemmap05.c: fix warnings in cleanup() Xiao Yang
2017-09-05  8:13 ` Li Wang
2017-09-06 14:02 ` Cyril Hrubis

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