From: Thomas Haller Date: Wed, 22 Feb 2023 15:32:03 +0000 (+0100) Subject: lib/randutils: drop unnecessary fcntl() in random_get_fd() X-Git-Tag: v2.39-rc1~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=261888f15873464b164ede5bb68aaecb06706f50;p=thirdparty%2Futil-linux.git lib/randutils: drop unnecessary fcntl() in random_get_fd() We already pass O_CLOEXEC flag to open(), no need to modify the file descriptor with FD_CLOEXEC afterwards. This was a left over from commit b1fa3e2234fa ('lib: use O_CLOEXEC in libcommon'). Signed-off-by: Thomas Haller --- diff --git a/lib/randutils.c b/lib/randutils.c index 2ffe9b4f06..15c2f78349 100644 --- a/lib/randutils.c +++ b/lib/randutils.c @@ -80,16 +80,11 @@ static void crank_random(void) int random_get_fd(void) { - int i, fd; + int fd; fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC); if (fd == -1) fd = open("/dev/random", O_RDONLY | O_NONBLOCK | O_CLOEXEC); - if (fd >= 0) { - i = fcntl(fd, F_GETFD); - if (i >= 0) - fcntl(fd, F_SETFD, i | FD_CLOEXEC); - } crank_random(); return fd; }