2019-11-27 00:11:08

by Iurii Zaikin

[permalink] [raw]
Subject: [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms.

Fixes the issue caused by the fact that in C in the expression
of the form -1234L only 1234L is the actual literal, the unary
minus is an operation applied to the literal. Which means that
to express the lower bound for the type one has to negate the
upper bound and subtract 1.

Signed-off-by: Iurii Zaikin <[email protected]>
---
fs/ext4/inode-test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/inode-test.c b/fs/ext4/inode-test.c
index 92a9da1774aa..bbce1c328d85 100644
--- a/fs/ext4/inode-test.c
+++ b/fs/ext4/inode-test.c
@@ -25,7 +25,7 @@
* For constructing the negative timestamp lower bound value.
* binary: 10000000 00000000 00000000 00000000
*/
-#define LOWER_MSB_1 (-0x80000000L)
+#define LOWER_MSB_1 (-(UPPER_MSB_0) - 1L) /* avoid overflow */
/*
* For constructing the negative timestamp upper bound value.
* binary: 11111111 11111111 11111111 11111111
--
2.24.0.432.g9d3f5f5b63-goog


2019-11-27 00:33:51

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms.

On 11/26/19 5:10 PM, Iurii Zaikin wrote:
> Fixes the issue caused by the fact that in C in the expression
> of the form -1234L only 1234L is the actual literal, the unary
> minus is an operation applied to the literal. Which means that
> to express the lower bound for the type one has to negate the
> upper bound and subtract 1.
>
> Signed-off-by: Iurii Zaikin <[email protected]>

Thanks for sending the patch quickly.

Please add Reported-by for Geert and also include the error he is
seeing in the commit log.
> ---
> fs/ext4/inode-test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/inode-test.c b/fs/ext4/inode-test.c
> index 92a9da1774aa..bbce1c328d85 100644
> --- a/fs/ext4/inode-test.c
> +++ b/fs/ext4/inode-test.c
> @@ -25,7 +25,7 @@
> * For constructing the negative timestamp lower bound value.
> * binary: 10000000 00000000 00000000 00000000
> */
> -#define LOWER_MSB_1 (-0x80000000L)
> +#define LOWER_MSB_1 (-(UPPER_MSB_0) - 1L) /* avoid overflow */
> /*
> * For constructing the negative timestamp upper bound value.
> * binary: 11111111 11111111 11111111 11111111
> --
> 2.24.0.432.g9d3f5f5b63-goog
>

thanks,
-- Shuah

2019-11-27 00:38:55

by Iurii Zaikin

[permalink] [raw]
Subject: Re: [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms.

> Please add Reported-by for Geert and also include the error he is
> seeing in the commit log.
Done