Skip to content

Conversation

@ttmut
Copy link
Contributor

@ttmut ttmut commented Oct 22, 2025

C standards prior to C23 do not allow variable declarations immediately after labels. Wrap such declarations in blocks to eliminate build warnings. Should hopefully fix the CI failure occurring in main https://github.com/zephyrproject-rtos/zephyr/actions/runs/18721827138/job/53395989790

Tested locally on native_sim:

$ west build -p -b native_sim/native tests/drivers/fuel_gauge/ltc2959 -T drivers.fuel_gauge.ltc2959 --
-DZEPHYR_TOOLCHAIN_VARIANT=llvm
/home/tahsin/zephyr/zephyr/drivers/fuel_gauge/ltc2959/ltc2959.c:465:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
  465 |                 uint8_t raw_st;
      |                 ^
/home/tahsin/zephyr/zephyr/drivers/fuel_gauge/ltc2959/ltc2959.c:478:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
  478 |                 uint16_t raw_voltage;
      |                 ^
/home/tahsin/zephyr/zephyr/drivers/fuel_gauge/ltc2959/ltc2959.c:495:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
  495 |                 uint16_t raw_current;
      |                 ^
/home/tahsin/zephyr/zephyr/drivers/fuel_gauge/ltc2959/ltc2959.c:511:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
  511 |                 uint16_t raw_temp;
      |                 ^
/home/tahsin/zephyr/zephyr/drivers/fuel_gauge/ltc2959/ltc2959.c:530:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
  530 |                 uint32_t acr;
      |                 ^
/home/tahsin/zephyr/zephyr/drivers/fuel_gauge/ltc2959/ltc2959.c:640:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
  640 |                 uint32_t counts = ltc2959_uah_to_counts(val.remaining_capacity, cfg);
      |                 ^
6 warnings generated.
[110/112] Linking C executable zephyr/zephyr.elf
Generating files from /home/tahsin/zephyr/zephyr/build/zephyr/zephyr.elf for board: native_sim
[112/112] Running utility command for native_runner_executable

Warnings go away after applying the patch:

-- west build: building application
[1/112] Preparing syscall dependency handling

[3/112] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.2.99 (/home/tahsin/zephyr/zephyr), build: v4.2.0-6706-g4842828358b5
[110/112] Linking C executable zephyr/zephyr.elf
Generating files from /home/tahsin/zephyr/zephyr/build/zephyr/zephyr.elf for board: native_sim
[112/112] Running utility command for native_runner_executable

@ttmut
Copy link
Contributor Author

ttmut commented Oct 22, 2025

#90356 (comment)

FYI @jhedberg

@ttmut ttmut force-pushed the fix/ltc2959_label branch from 4842828 to 73c734f Compare October 22, 2025 20:05
@jhedberg jhedberg added the Hotfix Fix for issues blocking development, i.e. upstream CI issues, tests failing in upstream CI , etc. label Oct 22, 2025
C standards prior to C23 do not allow variable declarations immediately
after labels. Wrap such declarations in blocks to eliminate build
warnings.

Signed-off-by: Tahsin Mutlugun <[email protected]>
@ttmut ttmut force-pushed the fix/ltc2959_label branch from 73c734f to e58e390 Compare October 22, 2025 20:10
@ttmut
Copy link
Contributor Author

ttmut commented Oct 22, 2025

Force-pushed to fix compliance failures regarding signed-off entries.

@sonarqubecloud
Copy link

@DBS06
Copy link
Contributor

DBS06 commented Oct 22, 2025

Interesting issue

@LostinTimeandspaceYT
Copy link
Contributor

@ttmut Thank you for patching this fix in!

@cfriedt cfriedt merged commit b1c497c into zephyrproject-rtos:main Oct 22, 2025
26 checks passed
@ttmut ttmut deleted the fix/ltc2959_label branch October 23, 2025 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Fuel Gauge Hotfix Fix for issues blocking development, i.e. upstream CI issues, tests failing in upstream CI , etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants