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.
diff --git a/tests/refs/normalize.c b/tests/refs/normalize.c
index 7f313ef..f9c525e 100644
--- a/tests/refs/normalize.c
+++ b/tests/refs/normalize.c
@@ -193,10 +193,7 @@ void test_refs_normalize__jgit_suite(void)
char c;
char buffer[GIT_REFNAME_MAX];
for (c = '\1'; c < ' '; c++) {
- strncpy(buffer, "refs/heads/mast", 15);
- strncpy(buffer + 15, (const char *)&c, 1);
- strncpy(buffer + 16, "er", 2);
- buffer[18 - 1] = '\0';
+ p_snprintf(buffer, sizeof(buffer), "refs/heads/mast%cer", c);
ensure_refname_invalid(GIT_REF_FORMAT_ALLOW_ONELEVEL, buffer);
}
}