Linux-kselftest Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms.
@ 2019-11-27 18:55 Iurii Zaikin
  2019-12-02 16:18 ` Brendan Higgins
  0 siblings, 1 reply; 7+ messages in thread
From: Iurii Zaikin @ 2019-11-27 18:55 UTC (permalink / raw)
  To: skhan, brendanhiggins, tytso, geert
  Cc: linux-ext4, linux-kselftest, kunit-dev, Iurii Zaikin

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.
Original error:
Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
test_data[i].expected.tv_sec == -2147483648
timestamp.tv_sec == 2147483648
1901-12-13 Lower bound of 32bit < 0 timestamp, no extra bits: msb:1
lower_bound:1 extra_bits: 0
Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
test_data[i].expected.tv_sec == 2147483648
timestamp.tv_sec == 6442450944
2038-01-19 Lower bound of 32bit <0 timestamp, lo extra sec bit on:
msb:1 lower_bound:1 extra_bits: 1
Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
test_data[i].expected.tv_sec == 6442450944
timestamp.tv_sec == 10737418240
2174-02-25 Lower bound of 32bit <0 timestamp, hi extra sec bit on:
msb:1 lower_bound:1 extra_bits: 2
not ok 1 - inode_test_xtimestamp_decoding
not ok 1 - ext4_inode_test

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Iurii Zaikin <yzaikin@google.com>
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms.
  2019-11-27 18:55 [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms Iurii Zaikin
@ 2019-12-02 16:18 ` Brendan Higgins
  0 siblings, 0 replies; 7+ messages in thread
From: Brendan Higgins @ 2019-12-02 16:18 UTC (permalink / raw)
  To: Iurii Zaikin
  Cc: Shuah Khan, Theodore Ts'o, geert, linux-ext4,
	open list:KERNEL SELFTEST FRAMEWORK, KUnit Development

On Wed, Nov 27, 2019 at 10:55 AM Iurii Zaikin <yzaikin@google.com> 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.
> Original error:
> Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
> test_data[i].expected.tv_sec == -2147483648
> timestamp.tv_sec == 2147483648
> 1901-12-13 Lower bound of 32bit < 0 timestamp, no extra bits: msb:1
> lower_bound:1 extra_bits: 0
> Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
> test_data[i].expected.tv_sec == 2147483648
> timestamp.tv_sec == 6442450944
> 2038-01-19 Lower bound of 32bit <0 timestamp, lo extra sec bit on:
> msb:1 lower_bound:1 extra_bits: 1
> Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
> test_data[i].expected.tv_sec == 6442450944
> timestamp.tv_sec == 10737418240
> 2174-02-25 Lower bound of 32bit <0 timestamp, hi extra sec bit on:
> msb:1 lower_bound:1 extra_bits: 2
> not ok 1 - inode_test_xtimestamp_decoding
> not ok 1 - ext4_inode_test
>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Iurii Zaikin <yzaikin@google.com>
> Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>

Acked-by: Brendan Higgins <brendanhiggins@google.com>

Thanks for taking care of this so quickly!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms.
  2019-11-27  0:37 Iurii Zaikin
@ 2019-11-27  7:29 ` Geert Uytterhoeven
  0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2019-11-27  7:29 UTC (permalink / raw)
  To: Iurii Zaikin
  Cc: Shuah Khan, Brendan Higgins, Theodore Tso, Ext4 Developers List,
	open list:KERNEL SELFTEST FRAMEWORK, kunit-dev

On Wed, Nov 27, 2019 at 1:37 AM Iurii Zaikin <yzaikin@google.com> 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.
> Original error:
> Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
> test_data[i].expected.tv_sec == -2147483648
> timestamp.tv_sec == 2147483648
> 1901-12-13 Lower bound of 32bit < 0 timestamp, no extra bits: msb:1
> lower_bound:1 extra_bits: 0
> Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
> test_data[i].expected.tv_sec == 2147483648
> timestamp.tv_sec == 6442450944
> 2038-01-19 Lower bound of 32bit <0 timestamp, lo extra sec bit on:
> msb:1 lower_bound:1 extra_bits: 1
> Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
> test_data[i].expected.tv_sec == 6442450944
> timestamp.tv_sec == 10737418240
> 2174-02-25 Lower bound of 32bit <0 timestamp, hi extra sec bit on:
> msb:1 lower_bound:1 extra_bits: 2
> not ok 1 - inode_test_xtimestamp_decoding
> not ok 1 - ext4_inode_test
>
> Reported-by: Geert Uytterhoeven geert@linux-m68k.org
> Signed-off-by: Iurii Zaikin <yzaikin@google.com>

Thanks, test succeeds (on m68k, arm32, and arm64)!

Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms.
  2019-11-27  0:33 ` Shuah Khan
@ 2019-11-27  0:37   ` Iurii Zaikin
  0 siblings, 0 replies; 7+ messages in thread
From: Iurii Zaikin @ 2019-11-27  0:37 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Brendan Higgins, Theodore Ts'o, Geert Uytterhoeven,
	Ext4 Developers List, open list:KERNEL SELFTEST FRAMEWORK,
	KUnit Development

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms.
@ 2019-11-27  0:37 Iurii Zaikin
  2019-11-27  7:29 ` Geert Uytterhoeven
  0 siblings, 1 reply; 7+ messages in thread
From: Iurii Zaikin @ 2019-11-27  0:37 UTC (permalink / raw)
  To: skhan, brendanhiggins, tytso, geert
  Cc: linux-ext4, linux-kselftest, kunit-dev, Iurii Zaikin

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.
Original error:
Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
test_data[i].expected.tv_sec == -2147483648
timestamp.tv_sec == 2147483648
1901-12-13 Lower bound of 32bit < 0 timestamp, no extra bits: msb:1
lower_bound:1 extra_bits: 0
Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
test_data[i].expected.tv_sec == 2147483648
timestamp.tv_sec == 6442450944
2038-01-19 Lower bound of 32bit <0 timestamp, lo extra sec bit on:
msb:1 lower_bound:1 extra_bits: 1
Expected test_data[i].expected.tv_sec == timestamp.tv_sec, but
test_data[i].expected.tv_sec == 6442450944
timestamp.tv_sec == 10737418240
2174-02-25 Lower bound of 32bit <0 timestamp, hi extra sec bit on:
msb:1 lower_bound:1 extra_bits: 2
not ok 1 - inode_test_xtimestamp_decoding
not ok 1 - ext4_inode_test

Reported-by: Geert Uytterhoeven geert@linux-m68k.org
Signed-off-by: Iurii Zaikin <yzaikin@google.com>
---
 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms.
  2019-11-27  0:10 Iurii Zaikin
@ 2019-11-27  0:33 ` Shuah Khan
  2019-11-27  0:37   ` Iurii Zaikin
  0 siblings, 1 reply; 7+ messages in thread
From: Shuah Khan @ 2019-11-27  0:33 UTC (permalink / raw)
  To: Iurii Zaikin, brendanhiggins, tytso, geert
  Cc: linux-ext4, linux-kselftest, kunit-dev, skh >> Shuah Khan

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 <yzaikin@google.com>

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms.
@ 2019-11-27  0:10 Iurii Zaikin
  2019-11-27  0:33 ` Shuah Khan
  0 siblings, 1 reply; 7+ messages in thread
From: Iurii Zaikin @ 2019-11-27  0:10 UTC (permalink / raw)
  To: skhan, brendanhiggins, tytso, geert
  Cc: linux-ext4, linux-kselftest, kunit-dev, Iurii Zaikin

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 <yzaikin@google.com>
---
 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27 18:55 [PATCH] fs/ext4/inode-test: Fix inode test on 32 bit platforms Iurii Zaikin
2019-12-02 16:18 ` Brendan Higgins
  -- strict thread matches above, loose matches on Subject: below --
2019-11-27  0:37 Iurii Zaikin
2019-11-27  7:29 ` Geert Uytterhoeven
2019-11-27  0:10 Iurii Zaikin
2019-11-27  0:33 ` Shuah Khan
2019-11-27  0:37   ` Iurii Zaikin

Linux-kselftest Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-kselftest/0 linux-kselftest/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-kselftest linux-kselftest/ https://lore.kernel.org/linux-kselftest \
		linux-kselftest@vger.kernel.org
	public-inbox-index linux-kselftest

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kselftest


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git