Code

main: don't show (null) as the server name
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>
Wed, 15 Jun 2011 20:00:24 +0000 (22:00 +0200)
committerMax Kellermann <max@duempel.org>
Thu, 23 Jun 2011 08:50:50 +0000 (10:50 +0200)
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

index 5b31f41a410dcec78d3cb907e41264cd18addeb3..185ca5d97405a25a2950ff6ba0520c13dc1d4d0d 100644 (file)
@@ -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
 }