From fed403c167706febbb261f994a3c0aea39c166ca Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 14 Oct 2013 09:26:41 +0200 Subject: daemon: Fix options parsing If an unknown option was passed to the daemon, it might fail to parse some of the passed options, and not take them into account. For example: "upower -d --timed-exit" would fail to exit Error out when an unknown option is passed. --- src/up-main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/up-main.c') diff --git a/src/up-main.c b/src/up-main.c index ba79685..f1d81a2 100644 --- a/src/up-main.c +++ b/src/up-main.c @@ -212,7 +212,11 @@ main (gint argc, gchar **argv) context = g_option_context_new ("upower daemon"); g_option_context_add_main_entries (context, options, NULL); - g_option_context_parse (context, &argc, &argv, NULL); + if (!g_option_context_parse (context, &argc, &argv, &error)) { + g_warning ("Failed to parse command-line options: %s", error->message); + g_error_free (error); + return 1; + } g_option_context_free (context); /* verbose? */ -- cgit v1.2.1