Re: [PATCH 01/12] libfrog: don't set negative errno in conversion functions

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

 



On 6/20/19 11:49 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> 
> Don't set errno to a negative value when we're converting integers.
> That's a kernel thing; this is userspace.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

<Doge stare>

and it's also "errno" fercryingoutloud ;)

Reviewed-by: Eric Sandeen <sandeen@xxxxxxxxxx>

> ---
>  libfrog/convert.c |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> 
> diff --git a/libfrog/convert.c b/libfrog/convert.c
> index ed4cae7f..62397507 100644
> --- a/libfrog/convert.c
> +++ b/libfrog/convert.c
> @@ -47,7 +47,7 @@ cvt_s64(
>  		return i;
>  
>  	/* Not all the input was consumed, return error. */
> -	errno = -ERANGE;
> +	errno = ERANGE;
>  	return INT64_MIN;
>  }
>  
> @@ -68,7 +68,7 @@ cvt_s32(
>  	if (errno)
>  		return i;
>  	if (i > INT32_MAX || i < INT32_MIN) {
> -		errno = -ERANGE;
> +		errno = ERANGE;
>  		return INT32_MIN;
>  	}
>  	return i;
> @@ -91,7 +91,7 @@ cvt_s16(
>  	if (errno)
>  		return i;
>  	if (i > INT16_MAX || i < INT16_MIN) {
> -		errno = -ERANGE;
> +		errno = ERANGE;
>  		return INT16_MIN;
>  	}
>  	return i;
> @@ -123,7 +123,7 @@ cvt_u64(
>  		return i;
>  
>  	/* Not all the input was consumed, return error. */
> -	errno = -ERANGE;
> +	errno = ERANGE;
>  	return UINT64_MAX;
>  }
>  
> @@ -144,7 +144,7 @@ cvt_u32(
>  	if (errno)
>  		return i;
>  	if (i > UINT32_MAX) {
> -		errno = -ERANGE;
> +		errno = ERANGE;
>  		return UINT32_MAX;
>  	}
>  	return i;
> @@ -167,7 +167,7 @@ cvt_u16(
>  	if (errno)
>  		return i;
>  	if (i > UINT16_MAX) {
> -		errno = -ERANGE;
> +		errno = ERANGE;
>  		return UINT16_MAX;
>  	}
>  	return i;
> 



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux