Skip to content

Conversation

kartben
Copy link
Contributor

@kartben kartben commented May 14, 2025

Compiler gets confused and thinks base may be used uninitialized. This shouldn't be possible, but to make the warning go away, initialize it.

Fixes CI issue in main https://github.com/zephyrproject-rtos/zephyr/actions/runs/15014534061/job/42189411225

@kartben kartben requested a review from cfriedt May 14, 2025 08:43
@kartben kartben added the Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc. label May 14, 2025
@kartben
Copy link
Contributor Author

kartben commented May 14, 2025

@cfriedt any chance you could also look into the other issue please?

INFO    - 1) sample.net.lwm2m_client.data_cache on qemu_x86/atom error (Build failure - undefined reference to `gettimeofday')

Setting CONFIG_XSI_SINGLE_PROCESS=y in samples/net/lwm2m_client/overlay-data-cache.conf does the trick but it doesn't sound right since AFAICS the LWM2M data cache feature doesn't really use any of the functions from this option group.
Thanks!

@kartben kartben marked this pull request as ready for review May 14, 2025 09:02
@github-actions github-actions bot added area: POSIX POSIX API Library size: XS A PR changing only a single line of code labels May 14, 2025
@github-actions github-actions bot requested a review from ycsin May 14, 2025 09:03
aescolar
aescolar previously approved these changes May 14, 2025
int z_clock_gettime(clockid_t clock_id, struct timespec *ts)
{
struct timespec base;
struct timespec base = {0};
Copy link
Member

Choose a reason for hiding this comment

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

This made L66 and 67 unnecessary, should we remove them?

Copy link
Member

Choose a reason for hiding this comment

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

I would agree with that - can you make that change, @kartben?

Monotonic is a bit of a hot path, so removing the additional 2+ memory writes would be a good thing.

Copy link
Member

Choose a reason for hiding this comment

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

I would move 66-67 before the switch, keep it explicit

Copy link
Member

Choose a reason for hiding this comment

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

66-67 shouldn't be needed with the variable initialized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please check the updated fix

@cfriedt
Copy link
Member

cfriedt commented May 14, 2025

Setting CONFIG_XSI_SINGLE_PROCESS=y in samples/net/lwm2m_client/overlay-data-cache.conf does the trick

That's a good short-term solution. I can make that change shortly.

I think the issue is that some libc functions use POSIX functions (maybe indirectly?).

Mentioned in #89068 as well.

Long term, I think it would be great to move some things into native Zephyr code.

Compiler gets confused and thinks base may be used uninitialized. This
shouldn't be possible, but to make the warning go away, initialize it.

Signed-off-by: Benjamin Cabé <[email protected]>

This comment was marked as off-topic.

@kartben kartben merged commit a3f6584 into zephyrproject-rtos:main May 14, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: POSIX POSIX API Library Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc. 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