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 <elene.mst@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11203>
This commit is contained in:
Eleni Maria Stea 2021-06-07 09:10:30 +03:00
parent d8bbb9daa2
commit 32b94df23e
1 changed files with 6 additions and 1 deletions

View File

@ -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);