[PATCH 2/6] wined3d: Use snprintf() in init_debug_buffer() (Coverity).
hverbeet at gmail.com
Thu Aug 16 05:19:09 CDT 2018
On 15 August 2018 at 13:39, Józef Kucia <jkucia at 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.
More information about the wine-devel