gallium/hud: use snprintf(..., "%s", ...) instead of strncpy

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 <corentin.noel@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18613>
This commit is contained in:
Corentin Noël
2022-09-15 14:55:52 +02:00
committed by Marge Bot
parent 9718c88baf
commit 4a1bde9fb0

View File

@@ -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);
}
}