fix(tx_pool): avoid pointer arithmetic on a void * in homa_copy_iter_to_frags - #96
Open
randomizedcoder wants to merge 1 commit into
Open
randomizedcoder wants to merge 1 commit into
randomizedcoder wants to merge 1 commit into
Conversation
…to_frags homa_copy_iter_to_frags() maps a page into `void *vaddr` and then does `vaddr + p_off` when calling copy_from_iter(). Arithmetic on a void pointer is a GNU extension and undefined in standard C (cppcheck: arithOperationsOnVoidPointer). Its sibling homa_copy_to_frags() already uses `u8 *vaddr`; match it. Verified: `cppcheck --enable=all homa_tx_pool.c` reports the finding at homa_tx_pool.c:534 before the change and nothing after; the existing homa_copy_iter_to_frags and homa_copy_to_frags unit tests stay green. Co-Authored-By: Claude Opus 4.8 <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.
Bug: pointer arithmetic on a
void *inhoma_copy_iter_to_frags()vaddr + p_offon avoid *is a GNU extension and undefined in standard C. The sibling functionhoma_copy_to_frags()a few lines up already declares its mapping asu8 *vaddr; this just makes the two consistent.Fix
Verification (static gate + regression)
cppcheck --enable=all homa_tx_pool.c. The existinghoma_copy_iter_to_fragsandhoma_copy_to_fragsunit tests both stay green (2/2) — the byte-copy behaviour is unchanged (u8 *and the previousvoid *arithmetic address the same bytes).