mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-25 01:00:03 +01:00
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
This commit is contained in:
parent
932a6a39e3
commit
4e83fabac1
1 changed files with 6 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue