Re: [PATCH i-g-t] lib/igt_sysfs: Let igt_sysfs_read|write return -errno

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxxxxxxx>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux