From 15e9d67b96c983cf0f7b4649851ac91ae22c6e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A8re=20Monseur?= Date: Sat, 8 Nov 2014 21:45:10 +0100 Subject: [PATCH] Fix return codes when displaying version, listing power supplies and icon types --- Changelog | 6 ++++++ cbatticon.c | 26 ++++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Changelog b/Changelog index 8ccd27b..2e8c03b 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,9 @@ +2014-11-08 Valère Monseur + + * Release 1.4.1 + + * Fix return codes when displaying version, listing power supplies and icon types + 2014-08-17 Valère Monseur * Release 1.4.0 diff --git a/cbatticon.c b/cbatticon.c index 7813d04..8faaa79 100644 --- a/cbatticon.c +++ b/cbatticon.c @@ -21,8 +21,8 @@ * with this program. If not, see . */ -#define CBATTICON_VERSION_NUMBER 1.4.0 -#define CBATTICON_VERSION_STRING "1.4.0" +#define CBATTICON_VERSION_NUMBER 1.4.1 +#define CBATTICON_VERSION_STRING "1.4.1" #include #include @@ -34,7 +34,7 @@ #include #include -static gboolean get_options (int argc, char **argv); +static gint get_options (int argc, char **argv); static gboolean get_power_supply (gchar *battery_suffix, gboolean list_power_supply); static gboolean get_sysattr_string (gchar *path, gchar *attribute, gchar **value); @@ -136,7 +136,7 @@ static GTimer *estimation_timer = NULL; * command line options function */ -static gboolean get_options (int argc, char **argv) +static gint get_options (int argc, char **argv) { GOptionContext *option_context; GError *error = NULL; @@ -170,7 +170,7 @@ static gboolean get_options (int argc, char **argv) g_printerr ("Cannot parse command line arguments: %s\n", error->message); g_error_free (error); error = NULL; - return FALSE; + return -1; } g_option_context_free (option_context); @@ -181,7 +181,7 @@ static gboolean get_options (int argc, char **argv) g_print ("cbatticon: a lightweight and fast battery icon that sits in your system tray\n"); g_print ("version %s\n", CBATTICON_VERSION_STRING); - return FALSE; + return 0; } /* option : list available power supplies (battery and AC) */ @@ -190,7 +190,7 @@ static gboolean get_options (int argc, char **argv) g_print ("List of available power supplies:\n"); get_power_supply (NULL, TRUE); - return FALSE; + return 0; } /* option : list available icon types */ @@ -205,7 +205,7 @@ static gboolean get_options (int argc, char **argv) g_print ("notification\t%s\n", HAS_NOTIFICATION_ICON_TYPE == TRUE ? "available" : "unavailable"); g_print ("symbolic\t%s\n" , HAS_SYMBOLIC_ICON_TYPE == TRUE ? "available" : "unavailable"); - return FALSE; + return 0; } /* option : set icon type */ @@ -257,7 +257,7 @@ static gboolean get_options (int argc, char **argv) g_printerr ("Critical level is higher than low level! They have been reset to default\n"); } - return TRUE; + return 1; } /* @@ -983,9 +983,11 @@ static gchar* get_icon_name (gint state, gint percentage) int main (int argc, char **argv) { - if (get_options (argc, argv) == FALSE) { - return -1; - } + gint ret; + + ret = get_options (argc, argv); + if (ret <= 0) + return ret; #ifdef WITH_NOTIFY if (configuration.hide_notification == FALSE) {