Skip to content

Conversation

tpambor
Copy link
Contributor

@tpambor tpambor commented Oct 8, 2025

Cast uintptr_t to unsigned long long and adjust format specifier accordingly to ensure compatibility on both 32-bit and 64-bit architectures.

Fixes the following warning:

/home/user/west_workspace/zephyr/tests/lib/c_lib/thrd/src/thrd.c: In function 'libc_thrd_test_thrd_create_join':
/home/user/west_workspace/zephyr/tests/lib/c_lib/thrd/src/thrd.c:82:41: error: format '%d' expects argument of type 'int', but argument 8 has type 'uintptr_t' {aka 'long unsigned int'} [-Werror=format=]
   82 |         zassert_equal(BIOS_FOOD, param, "expected: %d actual: %d", BIOS_FOOD, param);
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~             ~~~~~
      |                                                                               |
      |                                                                               uintptr_t {aka long unsigned int}

Part of: #96968

@zephyrbot zephyrbot added size: XS A PR changing only a single line of code area: C Library C Standard Library area: Tests Issues related to a particular existing or missing test labels Oct 8, 2025
@@ -79,7 +79,7 @@ ZTEST(libc_thrd, test_thrd_create_join)

zassert_equal(thrd_success, thrd_create(&thr, fun, &param));
zassert_equal(thrd_success, thrd_join(thr, &res));
zassert_equal(BIOS_FOOD, param, "expected: %d actual: %d", BIOS_FOOD, param);
zassert_equal(BIOS_FOOD, param, "expected: %u actual: %llu", BIOS_FOOD, (uint64_t)param);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being pedantic
either cast to unsigned long long int and use that llu specifier
or to uin64_t and use PRIu64

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to unsigned long long

@tpambor tpambor force-pushed the c11-thread-zassert branch 2 times, most recently from f7dd1d3 to caca6aa Compare October 8, 2025 14:30
Cast uintptr_t to unsigned long long and adjust format specifier
accordingly to ensure compatibility on both 32-bit and 64-bit
architectures.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
@tpambor tpambor force-pushed the c11-thread-zassert branch from caca6aa to 088c900 Compare October 8, 2025 14:31
Copy link

sonarqubecloud bot commented Oct 8, 2025

Please retry analysis of this Pull-Request directly on SonarQube Cloud

@cfriedt cfriedt merged commit 18d885d into zephyrproject-rtos:main Oct 12, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: C Library C Standard Library area: Tests Issues related to a particular existing or missing test size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants