From: Lennart Poettering Date: Tue, 20 Mar 2018 19:57:37 +0000 (+0100) Subject: coccinelle: always use fcntl(fd, FD_DUPFD, 3) instead of dup(fd) X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=74d8433aa68dd73a1ea04363d4d4fd30d90c49a2;p=elogind.git coccinelle: always use fcntl(fd, FD_DUPFD, 3) instead of dup(fd) Let's avoid fds 0…2 for safety reasons. --- diff --git a/src/test/test-fd-util.c b/src/test/test-fd-util.c index 3a53f80b3..f4b73f695 100644 --- a/src/test/test-fd-util.c +++ b/src/test/test-fd-util.c @@ -72,9 +72,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);