[PW_SID:1076232] cmpxchg: allow const-qualified old value in cmpxchg()#1705
[PW_SID:1076232] cmpxchg: allow const-qualified old value in cmpxchg()#1705linux-riscv-bot wants to merge 1 commit into
Conversation
The old value passed to cmpxchg() is semantically read-only: it is only loaded into a register as a comparand and is never written back. However, the macro currently assigns it implicitly to a local variable of type __typeof__(*(ptr)), which triggers -Werror=discarded-qualifiers when old is a const-qualified pointer and ptr points to a non-const type. To avoid this, let's add an explicit cast to __typeof__(*(ptr)) for the old local variable in the cmpxchg macros. This explicit cast suppresses the -Wdiscarded-qualifiers diagnostic. The new value is intentionally left without a cast: new will be stored into *ptr, so silently accepting a const-qualified new would allow callers to store a pointer-to-const into a non-const location without any compiler warning. Suggested-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
|
Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()" |
PR for series 1076232 applied to workflow__riscv__fixes
Name: cmpxchg: allow const-qualified old value in cmpxchg()
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1076232
Version: 1