pbio/main: Fix return type of pbio_main_start_application_resources. - #507
Open
CrispStrobe wants to merge 1 commit into
Open
CrispStrobe wants to merge 1 commit into
CrispStrobe wants to merge 1 commit into
Conversation
The header declared it as returning pbio_error_t, but it is defined as returning void and the only caller ignores the result. src/main.c did not include pbio/main.h, so the compiler never compared the two. With C calling conventions on ARM this happens to work, but it is undefined behavior, and on targets that check function signatures at link or call time it does not work: a WebAssembly build links with "function signature mismatch: pbio_main_start_application_resources" and the call traps. Make the declaration void, and include pbio/main.h in src/main.c so that a future mismatch is a compile error. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
lib/pbio/include/pbio/main.hdeclaresbut
lib/pbio/src/main.cdefines it asvoid, and the only caller(
lib/pbio/sys/main.c) ignores the result.src/main.cdoes not includepbio/main.h, so the compiler never compares the two. This is still true onmaster (8aa9986).
With the ARM calling convention this happens to work, but it is undefined
behaviour. On targets that check function signatures it fails: an emscripten
build links with
and the call traps at run time.
The fix makes the declaration
voidand includespbio/main.hinsrc/main.c, so any future mismatch is a compile error. Without the headerchange, the added include produces:
Both files compile cleanly with the fix (virtualhub flags,
-Wall -Werror).🤖 Generated with Claude Code