Skip to content

Conversation

@chggr
Copy link
Contributor

@chggr chggr commented Dec 7, 2025

When compiling with gcc 15.2.1 I get the following warning: pl_env.c:198:17: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation].

Having a look at the code, it seems that strncpy is used to copy a string where the specified length equals the source string length, resulting in no null terminator being written. The code is explicitly handing the string construction in this case, adding delimiters and a final null terminator later. So the null-padding behaviour of strncpy is not really needed and we should directly use memcpy instead to fix the truncation warning.

@chggr chggr force-pushed the fix-stringop-truncation-warning branch from 281ce6a to 9d2d58a Compare December 11, 2025 22:16
@flyingmutant flyingmutant merged commit 56446f7 into cmus:master Dec 12, 2025
6 checks passed
@chggr chggr deleted the fix-stringop-truncation-warning branch December 12, 2025 20:57
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.

3 participants