Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Mar 2019 03:02:55 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r345567 - projects/fuse2/tests/sys/fs/fusefs
Message-ID:  <201903270302.x2R32ti1057959@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Wed Mar 27 03:02:54 2019
New Revision: 345567
URL: https://svnweb.freebsd.org/changeset/base/345567

Log:
  fusefs: correct mmap()'s return value in the allow_other test
  
  Also, properly cleanup the semaphore.
  
  Reported by:	ngie
  Sponsored by:	The FreeBSD Foundation

Modified:
  projects/fuse2/tests/sys/fs/fusefs/allow_other.cc

Modified: projects/fuse2/tests/sys/fs/fusefs/allow_other.cc
==============================================================================
--- projects/fuse2/tests/sys/fs/fusefs/allow_other.cc	Wed Mar 27 02:57:59 2019	(r345566)
+++ projects/fuse2/tests/sys/fs/fusefs/allow_other.cc	Wed Mar 27 03:02:54 2019	(r345567)
@@ -107,7 +107,7 @@ TEST_F(AllowOther, allowed)
 	int mflags = MAP_ANON | MAP_SHARED;
 	
 	sem = (sem_t*)mmap(NULL, sizeof(*sem), mprot, mflags, -1, 0);
-	ASSERT_NE(NULL, sem) << strerror(errno);
+	ASSERT_NE(MAP_FAILED, sem) << strerror(errno);
 	ASSERT_EQ(0, sem_init(sem, 1, 0)) << strerror(errno);
 
 	if ((child = fork()) == 0) {
@@ -126,6 +126,7 @@ TEST_F(AllowOther, allowed)
 		}
 		_exit(0);
 
+		sem_destroy(sem);
 		/* Deliberately leak fd */
 	} else if (child > 0) {
 		int child_status;
@@ -149,6 +150,7 @@ TEST_F(AllowOther, allowed)
 	} else {
 		FAIL() << strerror(errno);
 	}
+	munmap(sem, sizeof(*sem));
 }
 
 TEST_F(NoAllowOther, disallowed)
@@ -161,7 +163,7 @@ TEST_F(NoAllowOther, disallowed)
 	int mflags = MAP_ANON | MAP_SHARED;
 
 	sem = (sem_t*)mmap(NULL, sizeof(*sem), mprot, mflags, -1, 0);
-	ASSERT_NE(NULL, sem) << strerror(errno);
+	ASSERT_NE(MAP_FAILED, sem) << strerror(errno);
 	ASSERT_EQ(0, sem_init(sem, 1, 0)) << strerror(errno);
 
 	if ((child = fork()) == 0) {
@@ -184,6 +186,7 @@ TEST_F(NoAllowOther, disallowed)
 		}
 		_exit(0);
 
+		sem_destroy(sem);
 		/* Deliberately leak fd */
 	} else if (child > 0) {
 		/* 
@@ -200,4 +203,5 @@ TEST_F(NoAllowOther, disallowed)
 	} else {
 		FAIL() << strerror(errno);
 	}
+	munmap(sem, sizeof(*sem));
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903270302.x2R32ti1057959>