From 4a1bde9fb0b77d6dbb112e777907f033d75b7fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Thu, 15 Sep 2022 14:55:52 +0200 Subject: [PATCH] gallium/hud: use snprintf(..., "%s", ...) instead of strncpy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a warning with stringop-truncation: ``` error: 'strncpy' output may be truncated copying 127 bytes from a string of length 255 [-Werror=stringop-truncation] 1443 | strncpy(graph->name, s, sizeof(graph->name)-1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Signed-off-by: Corentin Noël Part-of: --- src/gallium/auxiliary/hud/hud_context.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index ea0a294a320..242ca9faebe 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -1443,8 +1443,7 @@ hud_parse_env_var(struct hud_context *hud, struct pipe_screen *screen, if (added && !list_is_empty(&pane->graph_list)) { struct hud_graph *graph; graph = list_entry(pane->graph_list.prev, struct hud_graph, head); - strncpy(graph->name, s, sizeof(graph->name)-1); - graph->name[sizeof(graph->name)-1] = 0; + snprintf(graph->name, sizeof(graph->name), "%s", s); } }