From b774eac8d9b449ba2a78eafcc88f64251583e18d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Wed, 15 Jun 2011 22:00:24 +0200 Subject: [PATCH] main: don't show (null) as the server name With libmpdclient older than version 2.4.0, connection_settings_name() will return g_strdup(options.host), but options.host can be NULL. Return g_strdup("localhost") in that case, assuming localhost is mpd_connection_new's "default host". --- src/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 5b31f41..185ca5d 100644 --- a/src/main.c +++ b/src/main.c @@ -285,7 +285,13 @@ connection_settings_name(const struct mpd_connection *connection) return settings_name(settings); #else (void)connection; - return g_strdup(options.host); + + /* + * localhost is actually not correct, we only know that + * mpd_connection_new() has connected to the "default host". + */ + const char *name = options.host ?: "localhost"; + return g_strdup(name); #endif } -- 2.30.2