Re: [PATCH 2/3] crypto: digest: Return -errno if lseek() fails

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

 



On Wed, Jan 16, 2019 at 08:45:05PM -0800, Andrey Smirnov wrote:
> Strictly speaking, lseek() doesn't return a detailed error code as its
> return value and it can and should be obtained via 'errno'. In this
> case this change also allows us to avoid potential problems from
> downconverting 'loff_t' to 'int'.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
> ---
>  crypto/digest.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/crypto/digest.c b/crypto/digest.c
> index 493e56902..230db26e8 100644
> --- a/crypto/digest.c
> +++ b/crypto/digest.c
> @@ -226,9 +226,9 @@ static int digest_update_from_fd(struct digest *d, int fd,
>  	unsigned char *buf = xmalloc(PAGE_SIZE);
>  	int ret = 0;
>  
> -	ret = lseek(fd, start, SEEK_SET);
> -	if (ret == -1) {
> +	if (lseek(fd, start, SEEK_SET) != start) {
>  		perror("lseek");
> +		ret = -errno;
>  		goto out_free;
>  	}
Looks fine,
Reviewed-by: Sam Ravnborg <sam@xxxxxxxxxxxx>


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux