History

cmdutils: replace strncpy() with direct assignment

Only one character is actually rewritten. Fixes truncation warnings, such as warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation] in gcc 10.2.0

Anton Khirnov committed 5 years ago

Commit b334fd31 parent 7d095791 file · +2 −2Browse files

Showing the changes to fftools/cmdutils.c (1 of 1 file). Show all

Unified · Split

fftools/cmdutils.c+2−2
@@ -1163,13 +1163,13 @@ static void print_buildconf(int flags, int level) · 1162 unmodified lines
1163 // Change all the ' --' strings to '~--' so that1163 // Change all the ' --' strings to '~--' so that
1164 // they can be identified as tokens.1164 // they can be identified as tokens.
1165 while ((conflist = strstr(str, " --")) != NULL) {1165 while ((conflist = strstr(str, " --")) != NULL) {
1166 strncpy(conflist, "~--", 3);1166 conflist[0] = '~';
1167 }1167 }
1168 1168
1169 // Compensate for the weirdness this would cause1169 // Compensate for the weirdness this would cause
1170 // when passing 'pkg-config --static'.1170 // when passing 'pkg-config --static'.
1171 while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) {1171 while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) {
1172 strncpy(remove_tilde, "pkg-config ", 11);1172 remove_tilde[sizeof("pkg-config~") - 2] = ' ';
1173 }1173 }
1174 1174
1175 splitconf = strtok(str, "~");1175 splitconf = strtok(str, "~");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t