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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user