From ccc148fe9bc24a687ba868070014028d7ad0bb22 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 19 Apr 2016 13:14:00 +0200 Subject: libmm-glib,common-helpers: fix reading boolean from string The "0" case wasn't being handled properly: $ sudo mmcli -m 0 --create-bearer="apn=,allow-roaming=0" Error parsing properties string: 'Cannot get boolean from string '0'' --- libmm-glib/mm-common-helpers.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'libmm-glib/mm-common-helpers.c') diff --git a/libmm-glib/mm-common-helpers.c b/libmm-glib/mm-common-helpers.c index 804a9d40..c1ddd896 100644 --- a/libmm-glib/mm-common-helpers.c +++ b/libmm-glib/mm-common-helpers.c @@ -832,12 +832,13 @@ mm_common_get_boolean_from_string (const gchar *value, if (!g_ascii_strcasecmp (value, "true") || g_str_equal (value, "1")) return TRUE; - if (g_ascii_strcasecmp (value, "false") && g_str_equal (value, "0")) - g_set_error (error, - MM_CORE_ERROR, - MM_CORE_ERROR_INVALID_ARGS, - "Cannot get boolean from string '%s'", value); + if (!g_ascii_strcasecmp (value, "false") || g_str_equal (value, "0")) + return FALSE; + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot get boolean from string '%s'", value); return FALSE; } -- cgit v1.2.3-70-g09d2