Signed-off-by: Józef Kucia jkucia@codeweavers.com ---
This doesn't fix anything
--- dlls/wined3d/utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 491d888ad4c1..76f86334886b 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -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); }
static void debug_append(struct debug_buffer *buffer, const char *str, const char *separator) @@ -4355,7 +4355,7 @@ static void debug_append(struct debug_buffer *buffer, const char *str, const cha if (size == -1 || size >= buffer->size) { buffer->size = 0; - strcpy(&buffer->str[ARRAY_SIZE(buffer->str) - 4], "..."); + strcpy(&buffer->str[sizeof(buffer->str) - 4], "..."); return; }
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.