> specified bound depends on the length of the source argument [-Wstringop-truncation]
I believe the strncpy warning can be ignored because the buffer was reallocated using that size just before:
static void str_append(char **buf, const char *repr) { if (*buf) { *buf = realloc(*buf, strlen(*buf) + strlen(repr) + 1); assert(*buf); strncpy((*buf) + strlen(*buf), repr, strlen(repr) + 1); } else { *buf = strdup(repr); assert(*buf); } }
And we are copying into the middle of the reallocated buffer, not its start. Furthermore, this is test code.
> specified bound depends on the length of the source argument [-Wstringop- truncation]
I believe the strncpy warning can be ignored because the buffer was reallocated using that size just before:
static void str_append(char **buf, const char *repr)
assert( *buf);
strncpy( (*buf) + strlen(*buf), repr, strlen(repr) + 1);
assert( *buf);
{
if (*buf) {
*buf = realloc(*buf, strlen(*buf) + strlen(repr) + 1);
} else {
*buf = strdup(repr);
}
}
And we are copying into the middle of the reallocated buffer, not its start. Furthermore, this is test code.