From 83892fd9bbb0d6391caba74e66d5aaebc6310d6d Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Sun, 2 Jul 2017 16:40:20 -0700 Subject: [PATCH] glib plugin: fix per new random warning. --- src/glib/glibio.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/glib/glibio.c b/src/glib/glibio.c index ae5eb0a54..9ae154903 100644 --- a/src/glib/glibio.c +++ b/src/glib/glibio.c @@ -455,17 +455,19 @@ gpollfds_string (GSList * gpollfds) /* Construct a string describing the fds and r/w flags in GPOLLFDS, e.g. " 0(r)" */ - gchar * string = ""; + gchar * string = NULL; GSList * scan = gpollfds; while (scan != NULL) { GPollFD * gfd = scan->data; int mode = (gfd->events) & (~(G_IO_HUP|G_IO_ERR)); - gchar * next = g_strdup_printf ("%s %d(%s)", string, gfd->fd, - (mode == (G_IO_IN|G_IO_OUT) ? "rw" - : mode == G_IO_IN ? "r" - : mode == G_IO_OUT ? "w" : "?")); - if (string[0] != '\0') + gchar * next = g_strdup_printf ("%s %d(%s)", + (string == NULL ? "" : string), + gfd->fd, + (mode == (G_IO_IN|G_IO_OUT) ? "rw" + : mode == G_IO_IN ? "r" + : mode == G_IO_OUT ? "w" : "?")); + if (string != NULL) g_free (string); string = next; scan = scan->next; -- 2.25.1