Skip to content

Fix several compiler warnings#62

Merged
chrysn merged 29 commits intomainfrom
fix-warnings
Oct 20, 2023
Merged

Fix several compiler warnings#62
chrysn merged 29 commits intomainfrom
fix-warnings

Conversation

@chrysn
Copy link
Copy Markdown
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
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