Skip to content

Reduce warnings relevant to Zephyr platform#4658

Merged
lum1n0us merged 4 commits intobytecodealliance:mainfrom
project-ocre:remove-zephyr-warnings
Feb 6, 2026
Merged

Reduce warnings relevant to Zephyr platform#4658
lum1n0us merged 4 commits intobytecodealliance:mainfrom
project-ocre:remove-zephyr-warnings

Conversation

@kr-t
Copy link
Contributor

@kr-t kr-t commented Oct 6, 2025

This PR is intended to remove following warnings, when build in Zephyr application:

wasm-micro-runtime/core/shared/platform/zephyr/platform_internal.h:293: warning: "CLOCK_MONOTONIC" redefined
  293 | #define CLOCK_MONOTONIC 4
wasm-micro-runtime/core/shared/platform/zephyr/zephyr_file.c: In function 'zephyr_fs_alloc_obj':
wasm-micro-runtime/core/shared/platform/zephyr/zephyr_file.c:123:25: warning: implicit declaration of function 'bh_strdup' [-Wimplicit-function-declaration]
  123 |             ptr->path = bh_strdup(path);
      |                         ^~~~~~~~~
wasm-micro-runtime/core/shared/platform/zephyr/zephyr_file.c:123:23: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  123 |             ptr->path = bh_strdup(path);
      |                       ^
wasm-micro-runtime/core/shared/platform/zephyr/zephyr_file.c: In function 'os_renameat':
wasm-micro-runtime/core/shared/platform/zephyr/zephyr_file.c:853:35: warning: initialization of 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  853 |             char *new_path_copy = bh_strdup(new_path);
      |                                   ^~~~~~~~~
[45/462] Building C object CMakeFiles/app.dir/wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c.obj
wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c: In function 'wasmtime_ssp_poll_oneoff':
wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c:2216:42: warning: initialization of 'os_file_handle' {aka 'struct zephyr_handle *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
 2216 |                     os_file_handle tfd = fos[i]->file_handle->fd;
      |                                          ^~~
wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c:2222:31: warning: initialization of 'int' from 'os_file_handle' {aka 'struct zephyr_handle *'} makes integer from pointer without a cast [-Wint-conversion]
 2222 |                         .fd = tfd,
      |                               ^~~
wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c:2222:31: note: (near initialization for '(anonymous).fd')

Result - no warnings.

Tested in ocre as a zephyr application.

Updates:
there have been updates and changes after the initial commit and initial description. Please check those below in my follow-up comments.

@kr-t kr-t changed the title Remove warnings relevant to Zephyr platform Reduce warnings relevant to Zephyr platform Oct 6, 2025
@kr-t kr-t force-pushed the remove-zephyr-warnings branch 2 times, most recently from e79ae4b to 7639ed9 Compare October 6, 2025 11:36
@kr-t
Copy link
Contributor Author

kr-t commented Oct 6, 2025

Update after the initial commit:

Apparently, the CI doesn't like that in Zephyr's case I used int instead of os_file_handle. I have tried another way of refactoring the logic of how we abstract the os_file_handle tfd variable, but each time I have successfully removed warnings, the CI was unhappy with my changes and I couldn't pass all checks. Therefore, the changes in this PR in its current state leaves us with following - a successful CI, reduced amount of warnings and following warnings left:

wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c:2216:42: warning: initialization of 'os_file_handle' {aka 'struct zephyr_handle *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
 2216 |                     os_file_handle tfd = fos[i]->file_handle->fd;
      |                                          ^~~
wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c:2222:31: warning: initialization of 'int' from 'os_file_handle' {aka 'struct zephyr_handle *'} makes integer from pointer without a cast [-Wint-conversion]
 2222 |                         .fd = tfd,
      |                               ^~~
wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c:2222:31: note: (near initialization for '(anonymous).fd')

Fixing temporary workaround which was made in PR#4377 will probably help with these remaining warnings as well.

@kr-t kr-t force-pushed the remove-zephyr-warnings branch from 7639ed9 to bdfd724 Compare October 6, 2025 12:29
@lum1n0us
Copy link
Contributor

IMM, a better approach is to avoid using bh_xxx() functions in zephyr/zephyr_file.c. Instead, opt for a specific version that is compatible with Zephyr

@kr-t
Copy link
Contributor Author

kr-t commented Oct 16, 2025

Noted, will check out the alternatives.

@kr-t
Copy link
Contributor Author

kr-t commented Oct 21, 2025

Removed bh_strdup() function, therefore reducing the undeclared warning.
Since zephyr supports strdup() only when CONFIG_POSIX_C_LIB_EXT is selected, I didn't want to force users to use this, so I replaced strdup() with more generic strcpy().

kr-t added 4 commits October 28, 2025 07:33
Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
@kr-t kr-t force-pushed the remove-zephyr-warnings branch from 986174b to 50d92d3 Compare October 28, 2025 06:48
@lum1n0us lum1n0us added the bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs. label Oct 31, 2025
@lum1n0us lum1n0us merged commit c69c7e2 into bytecodealliance:main Feb 6, 2026
463 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants