From edf2533355ee9e725b649bdc914f12f15e975c94 Mon Sep 17 00:00:00 2001 From: Felix Abecassis Date: Mon, 8 Jul 2024 12:38:04 -0700 Subject: [PATCH] Use adequate type for storing the return value of read(2) Signed-off-by: Felix Abecassis --- pyxis_slurmstepd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyxis_slurmstepd.c b/pyxis_slurmstepd.c index 4a21baf..5b0cd22 100644 --- a/pyxis_slurmstepd.c +++ b/pyxis_slurmstepd.c @@ -510,6 +510,7 @@ static int read_proc_environ(pid_t pid, char **result, size_t *size) int fd = -1; char *buf = NULL; size_t len = 0, capacity = 1024; + ssize_t n; char *new_buf = NULL; int rv = -1; @@ -525,8 +526,8 @@ static int read_proc_environ(pid_t pid, char **result, size_t *size) if (buf == NULL) goto fail; - while ((ret = read(fd, buf + len, capacity - len)) > 0) { - len += ret; + while ((n = read(fd, buf + len, capacity - len)) > 0) { + len += n; if (capacity - len == 0) { /* Grow buffer. */ @@ -540,7 +541,7 @@ static int read_proc_environ(pid_t pid, char **result, size_t *size) } } - if (ret < 0) + if (n < 0) goto fail; /* From man 5 proc, there might not be a null byte at the end. */