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''
This commit is contained in:
Aleksander Morgado
2016-04-19 13:14:00 +02:00
parent 59f57befa4
commit ccc148fe9b

View File

@@ -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;
}