Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several compiler warnings #62

Merged
merged 29 commits into from
Oct 20, 2023
Merged

Fix several compiler warnings #62

merged 29 commits into from
Oct 20, 2023

Conversation

chrysn
Copy link
Member

@chrysn chrysn commented Oct 15, 2023

Most of this is refactoring around discouraged patterns, but the warnings found an actual error when what was meant to be leaking a refcounted pktsnip (because the C function is taking ownership of it) only leaked the (Copy, hence the complaint from the linter) pointer, leading to use-after-free / double-free. (A tests was added to catch this).

Set as a draft PR while I'm hunting the remaining warnings.

@chrysn chrysn marked this pull request as ready for review October 15, 2023 17:09
chrysn added 29 commits October 20, 2023 11:43
The `unreachable!` previously acted as a safeguard in case the
translation of C's "no return" indicator would not work, ensuring the
code path is not followed any further -- but the linter didn't like the
(currently) unreachable code. Instead, we now implicitly assert that the
panic function does not return by not explicitly having a return in that
branch.
The `forget()` call was on the (Copy, hence a warning that is being
fixed) raw pointer instead of the underlying refcounted structure,
leading to a double free.
The lint is right in that dropping the reference does little, but it
ensures that the reference is not held longer than the lock. Using an
explicit scope achieves the same without any discussions about the drop.
The module can exist and be tested without all of GNRC
@chrysn chrysn merged commit 7b8ec82 into main Oct 20, 2023
2 checks passed
@chrysn chrysn deleted the fix-warnings branch October 20, 2023 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant