Skip to contentSkip to conversation

hugemmap/hugemmap05.c: fix warnings in cleanup()

PATCH New Xiao Yang 3 participants 3 messages Aug 31, 2017 – Sep 6, 2017

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/1 hugemmap/hugemmap05.c: fix warnings in cleanup()

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.

---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c +3 -2
index 90389dd..c73a975 100644
@@ -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);
 	}
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 hugemmap/hugemmap05.c: fix warnings in cleanup()

After applying this patch, the warning is gone. Thanks!

safe_macros.c:62: WARN: hugemmap05.c:184: close(-1) failed: EBADF safe_macros.c:360: WARN: hugemmap05.c:185: unlink(hugemmap05/file)
failed: ENOENT

Signature · 2 lines
Li Wang
[email protected]