diff mbox series

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

Message ID 156104937602.1172531.10936665245404210667.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series xfsprogs-5.1: fix various problems | expand

Commit Message

Darrick J. Wong June 20, 2019, 4:49 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

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@oracle.com>
---
 libfrog/convert.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Eric Sandeen June 20, 2019, 6:58 p.m. UTC | #1
On 6/20/19 11:49 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> 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@oracle.com>

<Doge stare>

and it's also "errno" fercryingoutloud ;)

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  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;
>
Christoph Hellwig June 25, 2019, 11:02 a.m. UTC | #2
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

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;