From 0454e3e16f010e0bc14acfe302062b64647c0048 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 17 May 2016 15:36:21 +0200 Subject: [PATCH 2/2] up-tool: Exit early when connecting to upower fails This avoids spewing dozens of assertions like libupower-glib-CRITICAL **: up_client_get_devices: assertion 'UP_IS_CLIENT (client)' failed libupower-glib-CRITICAL **: up_device_get_object_path: assertion 'UP_IS_DEVICE (device)' failed and useless default values and then exiting successfully (which might confuse clients). Side issue in https://bugs.freedesktop.org/show_bug.cgi?id=95350 --- tools/up-tool.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/up-tool.c b/tools/up-tool.c index 44c7a9a..61978a0 100644 --- a/tools/up-tool.c +++ b/tools/up-tool.c @@ -286,6 +286,10 @@ main (int argc, char **argv) loop = g_main_loop_new (NULL, FALSE); client = up_client_new (); + if (!UP_IS_CLIENT(client)) { + g_warning("Cannot connect to upowerd"); + return EXIT_FAILURE; + } if (opt_version) { gchar *daemon_version; -- 2.7.4