On 15 August 2018 at 13:39, Józef Kucia jkucia@codeweavers.com wrote:
@@ -4340,9 +4340,9 @@ struct debug_buffer
static void init_debug_buffer(struct debug_buffer *buffer, const char *default_string) {
- strcpy(buffer->str, default_string);
- snprintf(buffer->str, sizeof(buffer->str), default_string); buffer->ptr = buffer->str;
- buffer->size = ARRAY_SIZE(buffer->str);
- buffer->size = sizeof(buffer->str);
}
I guess that's fine, although in general I don't know that we care all that much about shutting up the static analyzer in cases like these. You could conceivably implement init_debug_buffer() on top of debug_append(), in which case you'd even use the result of snprintf().
Semantically, using ARRAY_SIZE instead of sizeof makes sense; snprintf() return a character count, not a byte count.