From b8351111291cf305cd871f32a591c498fa748556 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 27 Jul 2014 02:20:00 +0200 Subject: [PATCH] libnm-util, core: fix warning about signed integer overflow (-Wstrict-overflow) gcc warns: make[4]: Entering directory `./NetworkManager/libnm-util' CC nm-value-transforms.lo nm-value-transforms.c: In function '_nm_utils_convert_op_array_to_string': nm-value-transforms.c:121:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] if (i > 0) ^ nm-value-transforms.c: In function '_nm_utils_convert_string_array_to_string': nm-value-transforms.c:121:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] if (i > 0) ^ make[7]: Entering directory `./NetworkManager/src/settings/plugins/ifcfg-rh' CC reader.lo reader.c: In function 'make_wired_setting': reader.c:3295:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] if (!found) ^ reader.c: In function 'wireless_connection_from_ifcfg': reader.c:3295:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] if (!found) ^ Signed-off-by: Thomas Haller --- libnm-util/nm-value-transforms.c | 2 +- src/settings/plugins/ifcfg-rh/reader.c | 3 ++- src/settings/plugins/ifnet/connection_parser.c | 3 ++- src/tests/test-general.c | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libnm-util/nm-value-transforms.c b/libnm-util/nm-value-transforms.c index 57da2dfa87..00e7e77579 100644 --- a/libnm-util/nm-value-transforms.c +++ b/libnm-util/nm-value-transforms.c @@ -114,7 +114,7 @@ static void _string_array_to_string (const GPtrArray *strings, GValue *dest_value) { GString *printable; - int i; + guint i; printable = g_string_new (NULL); for (i = 0; strings && i < strings->len; i++) { diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index af16d0dbf4..1753c51a50 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -3266,7 +3266,7 @@ fill_8021x (shvarFile *ifcfg, char *lower = NULL; lower = g_ascii_strdown (*iter, -1); - while (eap->method && !found) { + while (eap->method) { if (strcmp (eap->method, lower)) goto next; @@ -3287,6 +3287,7 @@ fill_8021x (shvarFile *ifcfg, } nm_setting_802_1x_add_eap_method (s_8021x, lower); found = TRUE; + break; next: eap++; diff --git a/src/settings/plugins/ifnet/connection_parser.c b/src/settings/plugins/ifnet/connection_parser.c index 85873d5f7b..32fccfc76d 100644 --- a/src/settings/plugins/ifnet/connection_parser.c +++ b/src/settings/plugins/ifnet/connection_parser.c @@ -1383,7 +1383,7 @@ fill_8021x (const char *ssid, char *lower = NULL; lower = g_ascii_strdown (*iter, -1); - while (eap->method && !found) { + while (eap->method) { if (strcmp (eap->method, lower)) goto next; @@ -1404,6 +1404,7 @@ fill_8021x (const char *ssid, } nm_setting_802_1x_add_eap_method (s_8021x, lower); found = TRUE; + break; next: eap++; diff --git a/src/tests/test-general.c b/src/tests/test-general.c index 723598e8e9..75ce96b79a 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -67,7 +67,7 @@ test_nm_utils_ascii_str_to_int64_do (const char *str, guint base, gint64 min, NULL, }; const char **ws_pre, **ws_post, **null; - int i; + guint i; if (str == NULL || exp_errno != 0) { test_nm_utils_ascii_str_to_int64_check (str, base, min, max, fallback, exp_errno, exp_val);