From 9718c88bafe87a87b143de1e00b8d1ef8ffe4e48 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Corentin=20No=C3=ABl?= Date: Thu, 15 Sep 2022 14:49:22 +0200 Subject: [PATCH] mesa/main: do not copy the exact size of the string MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This fixes a compiler warning with stringop-truncation: ``` error: 'strncpy' specified bound 4096 equals destination size [-Werror=stringop-truncation] 286 | strncpy(s, msg, MAX_DEBUG_MESSAGE_LENGTH); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Signed-off-by: Corentin Noël Part-of: --- src/mesa/main/errors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 10fe3fc..938b6e7 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -283,7 +283,7 @@ _mesa_gl_debug(struct gl_context *ctx, /* limit the message to fit within KHR_debug buffers */ char s[MAX_DEBUG_MESSAGE_LENGTH]; - strncpy(s, msg, MAX_DEBUG_MESSAGE_LENGTH); + strncpy(s, msg, MAX_DEBUG_MESSAGE_LENGTH - 1); s[MAX_DEBUG_MESSAGE_LENGTH - 1] = '\0'; len = MAX_DEBUG_MESSAGE_LENGTH - 1; _mesa_log_msg(ctx, source, type, *id, severity, len, s); -- 2.7.4