summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coccinelle/dup-fcntl.cocci5
-rw-r--r--src/test/test-fd-util.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/coccinelle/dup-fcntl.cocci b/coccinelle/dup-fcntl.cocci
new file mode 100644
index 0000000000..ef13564282
--- /dev/null
+++ b/coccinelle/dup-fcntl.cocci
@@ -0,0 +1,5 @@
+@@
+expression fd;
+@@
+- dup(fd)
++ fcntl(fd, F_DUPFD, 3)
diff --git a/src/test/test-fd-util.c b/src/test/test-fd-util.c
index 3f94df2eee..a43a285477 100644
--- a/src/test/test-fd-util.c
+++ b/src/test/test-fd-util.c
@@ -71,9 +71,9 @@ static void test_same_fd(void) {
_cleanup_close_ int a = -1, b = -1, c = -1;
assert_se(pipe2(p, O_CLOEXEC) >= 0);
- assert_se((a = dup(p[0])) >= 0);
+ assert_se((a = fcntl(p[0], F_DUPFD, 3)) >= 0);
assert_se((b = open("/dev/null", O_RDONLY|O_CLOEXEC)) >= 0);
- assert_se((c = dup(a)) >= 0);
+ assert_se((c = fcntl(a, F_DUPFD, 3)) >= 0);
assert_se(same_fd(p[0], p[0]) > 0);
assert_se(same_fd(p[1], p[1]) > 0);