每日 Harness 开源 · Source
返回本期 · Back to 2026-06-22

行业动态 · Industry News2026-06-22 · Monday, June 22, 2026

Linux eliminates the strncpy API after six years of work, 360 patches

phoronix.com原文 ↗

Linux 7.2 移除 `strncpy()` 是一项长线清理,不是表面 API 改名。Phoronix 写到它作为 bug 来源的原因包括 NUL termination 语义反直觉、目标缓冲区重复 zero-fill 带来的性能问题;整个替换过程持续约六年,累计约 362 个 commits。报道还列出替代路径:NUL 结尾用 `strscpy()`,需要 padding 用 `strscpy_pad()` 或 `strtomem_pad()`,已知长度则转向 `memcpy()` 等更明确语义。
浏览

评论 · Comments