From 7eb1257a8f3272fd68aec94dc0ad87ec6311d1dc Mon Sep 17 00:00:00 2001 From: William Wedler Date: Thu, 8 Aug 2024 14:13:36 -0400 Subject: [PATCH] pw-top: Limit length of formatted shortname to resolve build error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: "error: ā€˜%s’ directive output may be truncated writing likely 33 or more bytes into a region of size 10 [-Werror=format-truncation=]"" --- src/tools/pw-top.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/pw-top.c b/src/tools/pw-top.c index e0f558d76..dc99ef0af 100644 --- a/src/tools/pw-top.c +++ b/src/tools/pw-top.c @@ -253,7 +253,9 @@ static void node_param(void *data, int seq, { struct spa_audio_info_iec958 info = { 0 }; if (spa_format_audio_iec958_parse(param, &info) >= 0) { - snprintf(n->format, sizeof(n->format), "IEC958 %s %d", + /* MAX_FORMAT is 16 bytes + \0: 8 bytes in this string, upto 6 bytes for the rate, + * leaving us 2 for the format */ + snprintf(n->format, sizeof(n->format), "IEC958 %2.2s %d", spa_debug_type_find_short_name( spa_type_audio_iec958_codec, info.codec), info.rate);