Skip to content

[PW_SID:1076232] cmpxchg: allow const-qualified old value in cmpxchg()#1705

Closed
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw1076232
Closed

[PW_SID:1076232] cmpxchg: allow const-qualified old value in cmpxchg()#1705
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw1076232

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

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

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>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 137.51 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 2162.61 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 2930.42 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 32.69 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 4.39 seconds
Result: WARNING
Output:

WARNING: please, no spaces at the start of a line
#118: FILE: arch/powerpc/include/asm/cmpxchg.h:701:
+     __typeof__(*(ptr)) _o_ = (__typeof__(*(ptr)))(o);^I^I^I \$

WARNING: please, no spaces at the start of a line
#127: FILE: arch/powerpc/include/asm/cmpxchg.h:710:
+     __typeof__(*(ptr)) _o_ = (__typeof__(*(ptr)))(o);^I^I^I \$

WARNING: please, no spaces at the start of a line
#180: FILE: arch/sh/include/asm/cmpxchg.h:71:
+     __typeof__(*(ptr)) _o_ = (__typeof__(*(ptr)))(o);^I^I^I \$

WARNING: please, no spaces at the start of a line
#206: FILE: arch/sparc/include/asm/cmpxchg_64.h:173:
+     __typeof__(*(ptr)) _o_ = (__typeof__(*(ptr)))(o);^I^I^I \$

total: 0 errors, 4 warnings, 0 checks, 144 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 4de84c669397 ("cmpxchg: allow const-qualified old value in cmpxchg()") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 4 warnings, 0 checks, 144 lines checked
WARNING: please, no spaces at the start of a line


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 84.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
kdoc
Desc: Detects for kdoc errors
Duration: 0.88 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
module-param
Desc: Detect module_param changes
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "cmpxchg: allow const-qualified old value in cmpxchg()"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot deleted the pw1076232 branch April 3, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants