From 2fb89f607219e3893d76007e9920337f7676eb25 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 20 Mar 2017 17:06:02 +0100 Subject: [PATCH] main: improve strfsong() error check --- src/main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 72a9362..a8fb3b3 100644 --- a/src/main.c +++ b/src/main.c @@ -75,17 +75,18 @@ update_xterm_title(void) const struct mpd_song *song = mpd->song; char tmp[BUFSIZE]; + const char *new_title = NULL; if (options.xterm_title_format && mpd->playing && song) - strfsong(tmp, BUFSIZE, options.xterm_title_format, song); - else - *tmp = 0; + new_title = strfsong(tmp, BUFSIZE, options.xterm_title_format, song) > 0 + ? tmp + : NULL; - if (*tmp == 0) - g_strlcpy(tmp, PACKAGE " version " VERSION, BUFSIZE); + if (new_title == NULL) + new_title = PACKAGE " version " VERSION; static char title[BUFSIZE]; - if (strncmp(title, tmp, BUFSIZE)) { - g_strlcpy(title, tmp, BUFSIZE); + if (strncmp(title, new_title, BUFSIZE)) { + g_strlcpy(title, new_title, BUFSIZE); set_xterm_title(title); } } -- 2.30.2