diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-05-18 14:29:41 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-05-18 14:51:05 +0200 |
commit | d661d822f7fc2b31884eb10a586501765250ec2e (patch) | |
tree | f57c374c5d4f24a988e5fb54789fa10a2002fe04 /libmm-glib/mm-common-helpers.c | |
parent | 21ff48ed7d56837567aff3e396acf3bfd24cbc02 (diff) |
libmm-glib,common-helpers: avoid signed vs unsigned comparisons
mm-common-helpers.c: In function 'mm_get_int_from_str':
mm-common-helpers.c:1349:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (eol == num)
^~
mm-common-helpers.c: In function 'mm_utils_hexstr2bin':
mm-common-helpers.c:1718:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < len; i += 2) {
^
Diffstat (limited to 'libmm-glib/mm-common-helpers.c')
-rw-r--r-- | libmm-glib/mm-common-helpers.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libmm-glib/mm-common-helpers.c b/libmm-glib/mm-common-helpers.c index 36412768..58277930 100644 --- a/libmm-glib/mm-common-helpers.c +++ b/libmm-glib/mm-common-helpers.c @@ -1400,6 +1400,7 @@ mm_get_int_from_str (const gchar *str, gint *out) { glong num; + guint i; guint eol = 0; if (!str) @@ -1412,10 +1413,10 @@ mm_get_int_from_str (const gchar *str, if (!str[0]) return FALSE; - for (num = 0; str[num]; num++) { - if (str[num] != '+' && str[num] != '-' && !g_ascii_isdigit (str[num])) { + for (i = 0; str[i]; i++) { + if (str[i] != '+' && str[i] != '-' && !g_ascii_isdigit (str[i])) { /* ignore \r\n at the end of the string */ - if ((str[num] == '\r') || (str[num] == '\n')) { + if ((str[i] == '\r') || (str[i] == '\n')) { eol++; continue; } @@ -1426,7 +1427,7 @@ mm_get_int_from_str (const gchar *str, return FALSE; } /* if all characters were eol, the string is not parseable */ - if (eol == num) + if (eol == i) return FALSE; errno = 0; @@ -1794,7 +1795,7 @@ mm_utils_hexstr2bin (const gchar *hex, { const gchar *ipos = hex; g_autofree guint8 *buf = NULL; - gsize i; + gssize i; gint a; guint8 *opos; |