Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arch/risc-v/src/common/riscv_backtrace.c: Fix "error: pointer of type 'void *' used in arithmetic" #15725

Conversation

jlaitine
Copy link
Contributor

Summary

Fix a compilation error when using -Wpointer-arith and CONFIG_SCHED_BACKTRACE

Impact

Makes code to compile when using -Werror.

Testing

Tested on MPFS target, with the following flags added:

Tested compilation of "icicle/nsh" target, after adding the "CONFIG_SCHED_BACKTRACE=y" to boards/risc-v/mpfs/icicle/configs/nsh/defconfig.

The compilation command is:
"make EXTRAFLAGS=-Wpointer-arith -Werror"

With this patch, the compilation passes without warnings/errors. Without this patch the following warnings are produced:

common/riscv_backtrace.c:166:53: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
166 | rtcb->stack_base_ptr + rtcb->adj_stack_size,
| ^
common/riscv_backtrace.c:186:52: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
186 | rtcb->stack_base_ptr + rtcb->adj_stack_size,
| ^
common/riscv_backtrace.c:205:47: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
205 | tcb->stack_base_ptr + tcb->adj_stack_size,
| ^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:144: riscv_backtrace.o] Error 1
make: *** [tools/LibTargets.mk:170: arch/risc-v/src/libarch.a] Error 2

… 'void *' used in arithmetic"

Signed-off-by: Jukka Laitinen <[email protected]>
@github-actions github-actions bot added Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Size: S The size of the change in this PR is small labels Jan 30, 2025
@nuttxpr
Copy link

nuttxpr commented Jan 30, 2025

[Experimental Bot, please feedback here]

Yes, this PR meets the NuttX requirements. The summary clearly explains the problem and solution. The impact description is sufficient, focusing on the build impact. The testing section provides the necessary details about the test environment, build commands, and the observed results before and after the patch, demonstrating the fix. It would be improved by including the specific commit or PR branch being tested.

@xiaoxiang781216 xiaoxiang781216 merged commit 80e545a into apache:master Jan 30, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Size: S The size of the change in this PR is small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants