raspberrypi / FreeRTOS-Kernel

MIT License
16 stars 2 forks source link

[BUG] Small compiler warning (unused variable) #1

Open lurch opened 3 months ago

lurch commented 3 months ago

Describe the bug When building this on Ubuntu 24.04 as part of pico-examples and targeting PICO_BOARD=pico2 you get the following warning:

FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/port.c:2323:17: warning: variable 'ucCurrentPriority' set but not used [-Wunused-but-set-variable]
 2323 |         uint8_t ucCurrentPriority;
      |                 ^~~~~~~~~~~~~~~~~

Target

Host

To Reproduce

git clone --depth=1 https://github.com/raspberrypi/pico-sdk.git
git clone --depth=1 https://github.com/raspberrypi/pico-examples.git
git clone --depth=1 https://github.com/raspberrypi/FreeRTOS-Kernel
cmake -S pico-examples -B build_examples -DPICO_SDK_PATH=pico-sdk -DFREERTOS_KERNEL_PATH=FreeRTOS-Kernel -DPICO_BOARD=pico2
cmake --build build_examples/freertos/hello_freertos
lurch commented 3 months ago

Oh, although looking at https://github.com/raspberrypi/FreeRTOS-Kernel/blob/main/portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/port.c#L2320 I see that ucCurrentPriority is actually used inside a configASSERT so perhaps this is a red herring?

lurch commented 3 months ago

...and if I build for rp2350-riscv I get this similar-but-different warning:

[7826/7935] Building C object freertos/hello_freertos/C...S-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c.o
/maketest/git.FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c: In function 'xPortStartScheduler':
/maketest/git.FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c:351:25: warning: unused variable 'xISRStackTop' [-Wunused-variable]
  351 |             StackType_t xISRStackTop = xPortInitISRStack();
      |                         ^~~~~~~~~~~~
[7887/7935] Building C object freertos/hello_freertos/C...S-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c.o
/maketest/git.FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c: In function 'xPortStartSchedulerOnCore':
/maketest/git.FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c:265:25: warning: unused variable 'xISRStackTop' [-Wunused-variable]
  265 |             StackType_t xISRStackTop = xPortInitISRStack();
      |                         ^~~~~~~~~~~~

And like before, this warning is because these variables are only used inside a configASSERT. (So I assume this warning only appears in Release builds and would disappear in Debug builds)

ObligedTester commented 3 weeks ago

...and if I build for rp2350-riscv I get this similar-but-different warning:

[7826/7935] Building C object freertos/hello_freertos/C...S-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c.o
/maketest/git.FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c: In function 'xPortStartScheduler':
/maketest/git.FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c:351:25: warning: unused variable 'xISRStackTop' [-Wunused-variable]
  351 |             StackType_t xISRStackTop = xPortInitISRStack();
      |                         ^~~~~~~~~~~~
[7887/7935] Building C object freertos/hello_freertos/C...S-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c.o
/maketest/git.FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c: In function 'xPortStartSchedulerOnCore':
/maketest/git.FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_RISC-V/port.c:265:25: warning: unused variable 'xISRStackTop' [-Wunused-variable]
  265 |             StackType_t xISRStackTop = xPortInitISRStack();
      |                         ^~~~~~~~~~~~

And like before, this warning is because these variables are only used inside a configASSERT. (So I assume this warning only appears in Release builds and would disappear in Debug builds)

Can confirm this seem to only happen in Release build, building with debug the warning is not there.