Skip to content

[0040] 修复 s7.c 中 memmove 编译警告#790

Merged
da-liii merged 1 commit into
mainfrom
da/0040/cc_warning
May 17, 2026
Merged

[0040] 修复 s7.c 中 memmove 编译警告#790
da-liii merged 1 commit into
mainfrom
da/0040/cc_warning

Conversation

@da-liii
Copy link
Copy Markdown
Contributor

@da-liii da-liii commented May 17, 2026

Summary

  • 修复 src/s7.c:14298 处 GCC 的 -Wstringop-overflow 编译警告
  • 新增开发文档 devel/0040.md

What

insert_spaces 函数开头添加边界检查:

if ((spaces <= 0) || (len <= 0)) return;

Why

虽然所有调用者都已保证 width > len,但 GCC 静态分析器无法跨函数完全推导出 len 始终为非负数。当编译器考虑 len 为负值的可能性时,发现其转换为 size_t 后会变成巨大的无符号值,从而触发 -Wstringop-overflow 警告。这个无害的警告可能掩盖其他真正的溢出问题,并且在启用 -Werror 时会导致编译失败。

Test plan

  • xmake b goldfish 编译通过,警告消失

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@da-liii da-liii merged commit a4c57d8 into main May 17, 2026
4 checks passed
@da-liii da-liii deleted the da/0040/cc_warning branch May 17, 2026 06:25
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