[Intel-gfx] [PATCH i-g-t] lib/igt_sysfs: Let igt_sysfs_read|write return -errno
Chris Wilson
chris at chris-wilson.co.uk
Wed Dec 6 19:07:46 UTC 2017
Quoting Michal Wajdeczko (2017-12-06 19:00:22)
> In some cases debugfs or sysfs may return errors that we
> want to check. Return -errno from helper functions to make
> asserts easier.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> ---
> lib/igt_sysfs.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index e7c67da..9e9fdde 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -60,8 +60,8 @@ static int readN(int fd, char *buf, int len)
> if (ret < 0 && (errno == EINTR || errno == EAGAIN))
> continue;
>
> - if (ret <= 0)
> - return total ?: ret;
> + if (ret < 0)
> + return total ?: -errno;
We do need to keep the break on ret == 0; some fs will just keep on
reporting 0 bytes read for EOF.
How about
if (ret < 0) {
ret = -errno;
if (ret == -EINTR || ret == -EAGAIN)
continue;
}
if (ret <= 0)
return total ?: ret;
>
> total += ret;
> if (total == len)
> @@ -77,8 +77,8 @@ static int writeN(int fd, const char *buf, int len)
> if (ret < 0 && (errno == EINTR || errno == EAGAIN))
> continue;
>
> - if (ret <= 0)
> - return total ?: ret;
> + if (ret < 0)
> + return total ?: -errno;
Ditto.
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris
More information about the Intel-gfx
mailing list