[0040] 修复 s7.c 中 memmove 编译警告#790
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 <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.
Summary
src/s7.c:14298处 GCC 的-Wstringop-overflow编译警告devel/0040.mdWhat
在
insert_spaces函数开头添加边界检查:Why
虽然所有调用者都已保证
width > len,但 GCC 静态分析器无法跨函数完全推导出len始终为非负数。当编译器考虑len为负值的可能性时,发现其转换为size_t后会变成巨大的无符号值,从而触发-Wstringop-overflow警告。这个无害的警告可能掩盖其他真正的溢出问题,并且在启用-Werror时会导致编译失败。Test plan
xmake b goldfish编译通过,警告消失🤖 Generated with Claude Code