Skip to contentSkip to conversation

syscalls/futex: Get rid of futex_common.h

PATCH New Cyril Hrubis 1 participant 1 message Jun 20, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscalls/futex: Get rid of futex_common.h

There is no point in passing fd to anynomous mapping, the fd was ignored to begin with.

This commit just moves the mmap() to particular tests as there is no point in having helper just for one mmap() call and removes the futex_common.h completely.

---
 .../kernel/syscalls/futex/futex_common.h      | 46 -------------------
 .../kernel/syscalls/futex/futex_wait02.c      | 11 ++++-
 .../kernel/syscalls/futex/futex_wake03.c      | 11 ++++-
 3 files changed, 20 insertions(+), 48 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/futex/futex_common.h
testcases/kernel/syscalls/futex/futex_common.h deleted +0 -46
deleted file mode 100644
index 231fdc67e..000000000
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2015 Cyril Hrubis <[email protected]>
- *
- * Licensed under the GNU GPLv2 or later.
- * This program is free software;  you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY;  without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- * the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;  if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- /*
-  * Setups futex in shared memory needed for synchronization between multiple
-  * processes.
-  */
-
-static futex_t *futex;
-
-static void setup(void)
-{
-	int fd;
-
-	fd = shm_open("/LTP_futex_wait", O_RDWR | O_CREAT | O_EXCL, 0);
-
-	if (fd < 0) {
-		tst_brkm(TBROK | TERRNO, NULL,
-		         "shm_open(/LTP_futex_wait,O_RDWR|O_CREAT|O_EXCL,775)");
-	}
-	if (shm_unlink("/LTP_futex_wait"))
-		tst_brkm(TBROK | TERRNO, NULL, "shm_unlink(/LTP_futex_wait)");
-
-	futex = SAFE_MMAP(NULL, NULL, sizeof(*futex), PROT_READ | PROT_WRITE,
-			  MAP_ANONYMOUS | MAP_SHARED, fd, 0);
-
-	SAFE_CLOSE(NULL, fd);
-
-	*futex = FUTEX_INITIALIZER;
-}
testcases/kernel/syscalls/futex/futex_wait02.c +10 -1
index 2b863fe7c..1ca1df457 100644
@@ -29,11 +29,12 @@
 #include "test.h"
 #include "safe_macros.h"
 #include "futextest.h"
-#include "futex_common.h"
 
 const char *TCID="futex_wait02";
 const int TST_TOTAL=1;
 
+static futex_t *futex;
+
 static void do_child(void)
 {
 	int ret;
@@ -81,6 +82,14 @@ static void verify_futex_wait(void)
 		tst_resm(TFAIL, "child failed");
 }
 
+static void setup(void)
+{
+	futex = SAFE_MMAP(NULL, NULL, sizeof(*futex), PROT_READ | PROT_WRITE,
+			  MAP_ANONYMOUS | MAP_SHARED, -1, 0);
+
+	*futex = FUTEX_INITIALIZER;
+}
+
 int main(int argc, char *argv[])
 {
 	int lc;
testcases/kernel/syscalls/futex/futex_wake03.c +10 -1
index 523f32851..d6e5e5422 100644
@@ -27,11 +27,12 @@
 #include "test.h"
 #include "safe_macros.h"
 #include "futextest.h"
-#include "futex_common.h"
 
 const char *TCID="futex_wake03";
 const int TST_TOTAL=11;
 
+static futex_t *futex;
+
 static void do_child(void)
 {
 	futex_wait(futex, *futex, NULL, 0);
@@ -103,6 +104,14 @@ static void verify_futex_wake(void)
 	}
 }
 
+static void setup(void)
+{
+	futex = SAFE_MMAP(NULL, NULL, sizeof(*futex), PROT_READ | PROT_WRITE,
+			  MAP_ANONYMOUS | MAP_SHARED, -1, 0);
+
+	*futex = FUTEX_INITIALIZER;
+}
+
 int main(int argc, char *argv[])
 {
 	int lc;
Signature · 1 line
2.19.2