Skip to content

Commit 0750d0c

Browse files
committed
tests: refs::normalize: simplify code to avoid GCC warning
Since version 8.1, GCC will do some automatic bounds checking when printing static content into a buffer with known size. The bounds checking doesn't yet work quite right in all scenarios and may thus lead to false positives. Fix one of these false positives in refs::normalize by simplifying the code.
1 parent ba5e39a commit 0750d0c

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

tests/refs/normalize.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,7 @@ void test_refs_normalize__jgit_suite(void)
193193
char c;
194194
char buffer[GIT_REFNAME_MAX];
195195
for (c = '\1'; c < ' '; c++) {
196-
strncpy(buffer, "refs/heads/mast", 15);
197-
strncpy(buffer + 15, (const char *)&c, 1);
198-
strncpy(buffer + 16, "er", 2);
199-
buffer[18 - 1] = '\0';
196+
p_snprintf(buffer, sizeof(buffer), "refs/heads/mast%cer", c);
200197
ensure_refname_invalid(GIT_REF_FORMAT_ALLOW_ONELEVEL, buffer);
201198
}
202199
}

0 commit comments

Comments
 (0)