From: Jonathan Neuschäfer Date: Wed, 15 Jun 2011 20:00:24 +0000 (+0200) Subject: main: don't show (null) as the server name X-Git-Tag: release-0.19~16 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b774eac8d9b449ba2a78eafcc88f64251583e18d;p=ncmpc.git 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". --- 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 }