From cbfcb2373c709d37cdb5e14de8125e5f880f8009 Mon Sep 17 00:00:00 2001 From: Lukasz Pawelczyk Date: Thu, 9 Apr 2020 17:51:15 +0200 Subject: [PATCH] Use TEMP_FAILTURE_RETRY instead of checking EINTR by hand Change-Id: Ic1c97915c98bfa26cc04f28adf3d3292ef157aa2 --- src/crypto.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/crypto.c b/src/crypto.c index 98e5a19..a22d9c5 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -68,17 +68,13 @@ static int getrandom_wrapper(unsigned char *buf, int num) while (remaining > 0) { #ifdef SYS_getrandom - ssize_t n = syscall(SYS_getrandom, buf + received, remaining, 0); + ssize_t n = TEMP_FAILURE_RETRY(syscall(SYS_getrandom, buf + received, remaining, 0)); #else /* SYS_getrandom */ - ssize_t n = read(urandom_fd, buf + received, remaining); + ssize_t n = TEMP_FAILURE_RETRY(read(urandom_fd, buf + received, remaining)); #endif /* SYS_getrandom */ - if (n == -1) { - if (errno == EINTR) - continue; - + if (n == -1) return 0; - } received += n; remaining -= n; -- 2.34.1