[Spice-devel] [PATCH spice-gtk 1/6] channel: return "unknown" in spice_channel_type_to_string()
marcandre.lureau at redhat.com
marcandre.lureau at redhat.com
Thu Aug 10 21:02:48 UTC 2017
From: Marc-André Lureau <marcandre.lureau at redhat.com>
This fixes the following gcc warning:
spice-channel.c: In function ‘spice_channel_constructed’:
spice-channel.c:144:41: error: ‘%s’ directive output may be truncated writing likely 20 or more bytes into a region of size 16 [-Werror=format-truncation=]
snprintf(c->name, sizeof(c->name), "%s-%d:%d",
^~
spice-channel.c:144:40: note: assuming directive output of 20 bytes
snprintf(c->name, sizeof(c->name), "%s-%d:%d",
Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
src/spice-channel.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/spice-channel.c b/src/spice-channel.c
index 4c3db9d..7cd6251 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -2130,13 +2130,13 @@ static const char *to_string[] = {
**/
const gchar* spice_channel_type_to_string(gint type)
{
- const char *str = NULL;
+ const char *str = "unknown";
if (type >= 0 && type < G_N_ELEMENTS(to_string)) {
str = to_string[type];
}
- return str ? str : "unknown channel type";
+ return str;
}
/**
--
2.14.0.1.geff633fa0
More information about the Spice-devel
mailing list