diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2016-05-17 15:36:21 +0200 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2016-05-18 14:58:53 +0200 |
commit | 4e83fabac13250fdc61ef5db817e82c32b7b301b (patch) | |
tree | a88a93754996e3275a71f743c9b1d3ed7c3c2dca /tools | |
parent | 932a6a39e35754be571e1274aec4730fd42dba13 (diff) | |
download | upower-4e83fabac13250fdc61ef5db817e82c32b7b301b.tar.gz |
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
users or scripts trying to parse the output).
Use the new up_client_new_full() constructor so that we get a proper GError.
Side issue in https://bugs.freedesktop.org/show_bug.cgi?id=95350
Diffstat (limited to 'tools')
-rw-r--r-- | tools/up-tool.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/up-tool.c b/tools/up-tool.c index 44c7a9a..db31075 100644 --- a/tools/up-tool.c +++ b/tools/up-tool.c @@ -285,7 +285,12 @@ main (int argc, char **argv) g_option_context_free (context); loop = g_main_loop_new (NULL, FALSE); - client = up_client_new (); + client = up_client_new_full (NULL, &error); + if (client == NULL) { + g_warning ("Cannot connect to upowerd: %s", error->message); + g_error_free (error); + return EXIT_FAILURE; + } if (opt_version) { gchar *daemon_version; |