From 32b94df23e1a156edfc0759f9c582afabf85b01a Mon Sep 17 00:00:00 2001 From: Eleni Maria Stea Date: Mon, 7 Jun 2021 09:10:30 +0300 Subject: [PATCH] util: replaced ENODATA with ENOATTR for non-Linux systems On Linux ENODATA is defined but on BSD, and MacOSX ENOATTR is used instead. Defined ENODATA to be ENOATTR when the system is not Linux. v2: Replaced ENODATA and ENOATTR with -EFAULT that is exists everywhere and added a comment (Ian Romanick) Signed-off-by: Eleni Maria Stea Reviewed-by: Ian Romanick Part-of: --- src/util/os_file.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util/os_file.c b/src/util/os_file.c index 1c30df6486a..5f79284e083 100644 --- a/src/util/os_file.c +++ b/src/util/os_file.c @@ -89,7 +89,12 @@ typedef ptrdiff_t ssize_t; static ssize_t readN(int fd, char *buf, size_t len) { - int err = -ENODATA; + /* err was initially set to -ENODATA but in some BSD systems + * ENODATA is not defined and ENOATTR is used instead. + * As err is not returned by any function it can be initialized + * to -EFAULT that exists everywhere. + */ + int err = -EFAULT; size_t total = 0; do { ssize_t ret = read(fd, buf + total, len - total);