keyfile: minor cleanup in get_one_int() to use _nm_utils_ascii_str_to_int64()

This commit is contained in:
Thomas Haller
2017-10-04 11:14:48 +02:00
parent 102a58bb62
commit 72c28cb6bc

View File

@@ -133,8 +133,7 @@ read_array_of_uint (GKeyFile *file,
static gboolean static gboolean
get_one_int (KeyfileReaderInfo *info, const char *property_name, const char *str, guint32 max_val, guint32 *out) get_one_int (KeyfileReaderInfo *info, const char *property_name, const char *str, guint32 max_val, guint32 *out)
{ {
long tmp; gint64 tmp;
char *endptr;
g_return_val_if_fail (!info == !property_name, FALSE); g_return_val_if_fail (!info == !property_name, FALSE);
@@ -145,13 +144,13 @@ get_one_int (KeyfileReaderInfo *info, const char *property_name, const char *str
return FALSE; return FALSE;
} }
errno = 0; tmp = _nm_utils_ascii_str_to_int64 (str, 10, 0, max_val, -1);
tmp = strtol (str, &endptr, 10); if (tmp == -1) {
if (errno || (tmp < 0) || (tmp > max_val) || *endptr != 0) { if (property_name) {
if (property_name)
handle_warn (info, property_name, NM_KEYFILE_WARN_SEVERITY_WARN, handle_warn (info, property_name, NM_KEYFILE_WARN_SEVERITY_WARN,
_("ignoring invalid number '%s'"), _("ignoring invalid number '%s'"),
str); str);
}
return FALSE; return FALSE;
} }