* [PATCH] CodeSamples/formal: Add pointer cast in WRITE_ONCE() for Linux v5.8 compat
@ 2020-09-26 3:32 Akira Yokosawa
2020-09-26 14:39 ` Paul E. McKenney
0 siblings, 1 reply; 2+ messages in thread
From: Akira Yokosawa @ 2020-09-26 3:32 UTC (permalink / raw)
To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa
From 456d16d1450416bbd4eeea175a4bc0c2f819062d Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@gmail.com>
Date: Sat, 26 Sep 2020 12:11:37 +0900
Subject: [PATCH] CodeSamples/formal: Add pointer cast in WRITE_ONCE() for Linux v5.8 compat
On Linux v5.8, "make" under klitmus/ after "make cross-klitmus" at
CodeSamples/formal/herd/ doesn't complete with the following error:
In file included from ./include/linux/export.h:43,
from ./include/linux/linkage.h:7,
from ./include/linux/kernel.h:8,
from ./include/linux/list.h:9,
from ./include/linux/module.h:12,
from [...]/CodeSamples/fromal/herd/klitmus/litmus030.c:11:
[...]/CodeSamples/formal/herd/klitmus/litmus030.c: In function 'code0':
./include/linux/compiler.h:297:30: error: assignment to 'int * volatile'
from incomatible pointer type 'int **' [-Werror=incompatible-pointer-types]
297 | *(volatile typeof(x) *)&(x) = (val); \
| ^
./include/linux/compiler.h:303:2: note: in expansion of macro '__WRITE_ONCE'
303 | __WRITE_ONCE(x, val); \
| ^~~~~~~~~~~~
[...]/CodeSamples/formal/herd/klitmus/litmus030.c:363:2: note: in expansion
of macro 'WRITE_ONCE'
363 | WRITE_ONCE(*x, x);
| ^~~~~~~~~~
cc1: some warnings being treated as errors
This is due to the simplification of WRITE_ONCE() [1].
Now WRITE_ONCE() catches type mismatch of its arguments.
Adding a pointer cast to the WRITE_ONCE() argumant:
WRITE_ONCE(*x, (int*)x);
makes the compiler happy.
[1]: https://git.kernel.org/linus/a5460b5e5fb8
("READ_ONCE: Simplify implementations of {READ,WRITE}_ONCE()")
NOTE1: These litmus tests are converted from those under
CodeSamples/formal/litmus/.
NOTE2: They were once presented as code snippets in perfbook.
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
CodeSamples/formal/litmus/C-WWC+o+o-data-o+o-addr-o.litmus | 2 +-
CodeSamples/formal/litmus/C-WWC+o+o-r+o-addr-o.litmus | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/CodeSamples/formal/litmus/C-WWC+o+o-data-o+o-addr-o.litmus b/CodeSamples/formal/litmus/C-WWC+o+o-data-o+o-addr-o.litmus
index cd9df060..3525e033 100644
--- a/CodeSamples/formal/litmus/C-WWC+o+o-data-o+o-addr-o.litmus
+++ b/CodeSamples/formal/litmus/C-WWC+o+o-data-o+o-addr-o.litmus
@@ -13,7 +13,7 @@ int *y = &b;
P0(int **x)
{
- WRITE_ONCE(*x, x);
+ WRITE_ONCE(*x, (int*)x);
}
P1(int **x, int **y)
diff --git a/CodeSamples/formal/litmus/C-WWC+o+o-r+o-addr-o.litmus b/CodeSamples/formal/litmus/C-WWC+o+o-r+o-addr-o.litmus
index 6a65d674..0d16b2f7 100644
--- a/CodeSamples/formal/litmus/C-WWC+o+o-r+o-addr-o.litmus
+++ b/CodeSamples/formal/litmus/C-WWC+o+o-r+o-addr-o.litmus
@@ -13,7 +13,7 @@ int *y = &b;
P0(int **x)
{
- WRITE_ONCE(*x, x);
+ WRITE_ONCE(*x, (int*)x);
}
P1(int **x, int **y)
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] CodeSamples/formal: Add pointer cast in WRITE_ONCE() for Linux v5.8 compat
2020-09-26 3:32 [PATCH] CodeSamples/formal: Add pointer cast in WRITE_ONCE() for Linux v5.8 compat Akira Yokosawa
@ 2020-09-26 14:39 ` Paul E. McKenney
0 siblings, 0 replies; 2+ messages in thread
From: Paul E. McKenney @ 2020-09-26 14:39 UTC (permalink / raw)
To: Akira Yokosawa; +Cc: perfbook
On Sat, Sep 26, 2020 at 12:32:28PM +0900, Akira Yokosawa wrote:
> >From 456d16d1450416bbd4eeea175a4bc0c2f819062d Mon Sep 17 00:00:00 2001
> From: Akira Yokosawa <akiyks@gmail.com>
> Date: Sat, 26 Sep 2020 12:11:37 +0900
> Subject: [PATCH] CodeSamples/formal: Add pointer cast in WRITE_ONCE() for Linux v5.8 compat
>
> On Linux v5.8, "make" under klitmus/ after "make cross-klitmus" at
> CodeSamples/formal/herd/ doesn't complete with the following error:
>
> In file included from ./include/linux/export.h:43,
> from ./include/linux/linkage.h:7,
> from ./include/linux/kernel.h:8,
> from ./include/linux/list.h:9,
> from ./include/linux/module.h:12,
> from [...]/CodeSamples/fromal/herd/klitmus/litmus030.c:11:
> [...]/CodeSamples/formal/herd/klitmus/litmus030.c: In function 'code0':
> ./include/linux/compiler.h:297:30: error: assignment to 'int * volatile'
> from incomatible pointer type 'int **' [-Werror=incompatible-pointer-types]
> 297 | *(volatile typeof(x) *)&(x) = (val); \
> | ^
>
> ./include/linux/compiler.h:303:2: note: in expansion of macro '__WRITE_ONCE'
> 303 | __WRITE_ONCE(x, val); \
> | ^~~~~~~~~~~~
>
> [...]/CodeSamples/formal/herd/klitmus/litmus030.c:363:2: note: in expansion
> of macro 'WRITE_ONCE'
> 363 | WRITE_ONCE(*x, x);
> | ^~~~~~~~~~
>
> cc1: some warnings being treated as errors
>
> This is due to the simplification of WRITE_ONCE() [1].
> Now WRITE_ONCE() catches type mismatch of its arguments.
>
> Adding a pointer cast to the WRITE_ONCE() argumant:
>
> WRITE_ONCE(*x, (int*)x);
>
> makes the compiler happy.
>
> [1]: https://git.kernel.org/linus/a5460b5e5fb8
> ("READ_ONCE: Simplify implementations of {READ,WRITE}_ONCE()")
>
> NOTE1: These litmus tests are converted from those under
> CodeSamples/formal/litmus/.
> NOTE2: They were once presented as code snippets in perfbook.
>
> Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Good catch, queued and pushed, thank you!!!
Thanx, Paul
> ---
> CodeSamples/formal/litmus/C-WWC+o+o-data-o+o-addr-o.litmus | 2 +-
> CodeSamples/formal/litmus/C-WWC+o+o-r+o-addr-o.litmus | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/CodeSamples/formal/litmus/C-WWC+o+o-data-o+o-addr-o.litmus b/CodeSamples/formal/litmus/C-WWC+o+o-data-o+o-addr-o.litmus
> index cd9df060..3525e033 100644
> --- a/CodeSamples/formal/litmus/C-WWC+o+o-data-o+o-addr-o.litmus
> +++ b/CodeSamples/formal/litmus/C-WWC+o+o-data-o+o-addr-o.litmus
> @@ -13,7 +13,7 @@ int *y = &b;
>
> P0(int **x)
> {
> - WRITE_ONCE(*x, x);
> + WRITE_ONCE(*x, (int*)x);
> }
>
> P1(int **x, int **y)
> diff --git a/CodeSamples/formal/litmus/C-WWC+o+o-r+o-addr-o.litmus b/CodeSamples/formal/litmus/C-WWC+o+o-r+o-addr-o.litmus
> index 6a65d674..0d16b2f7 100644
> --- a/CodeSamples/formal/litmus/C-WWC+o+o-r+o-addr-o.litmus
> +++ b/CodeSamples/formal/litmus/C-WWC+o+o-r+o-addr-o.litmus
> @@ -13,7 +13,7 @@ int *y = &b;
>
> P0(int **x)
> {
> - WRITE_ONCE(*x, x);
> + WRITE_ONCE(*x, (int*)x);
> }
>
> P1(int **x, int **y)
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-26 14:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-26 3:32 [PATCH] CodeSamples/formal: Add pointer cast in WRITE_ONCE() for Linux v5.8 compat Akira Yokosawa
2020-09-26 14:39 ` Paul E. McKenney
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.