diff --git a/cli/src/connections.c b/cli/src/connections.c index d17f7f1264..b758ad5773 100644 --- a/cli/src/connections.c +++ b/cli/src/connections.c @@ -2203,17 +2203,6 @@ static const NameItem nmc_cdma_settings [] = { { NULL, NULL, NULL, FALSE } }; -static const NameItem nmc_mobile_settings [] = { - { NM_SETTING_CONNECTION_SETTING_NAME, NULL, NULL, TRUE }, - { NM_SETTING_SERIAL_SETTING_NAME, NULL, NULL, FALSE }, - { NM_SETTING_PPP_SETTING_NAME, NULL, NULL, FALSE }, - { NM_SETTING_GSM_SETTING_NAME, NULL, NULL, TRUE }, - { NM_SETTING_CDMA_SETTING_NAME, NULL, NULL, TRUE }, - { NM_SETTING_IP4_CONFIG_SETTING_NAME, NULL, NULL, FALSE }, - { NM_SETTING_IP6_CONFIG_SETTING_NAME, NULL, NULL, FALSE }, - { NULL, NULL, NULL, FALSE } -}; - static const NameItem nmc_bluetooth_settings [] = { { NM_SETTING_CONNECTION_SETTING_NAME, NULL, NULL, TRUE }, { NM_SETTING_BLUETOOTH_SETTING_NAME, NULL, NULL, TRUE }, @@ -2529,6 +2518,9 @@ check_and_convert_mtu (const char *mtu, guint32 *mtu_int, GError **error) { unsigned long local_mtu_int; + if (mtu_int) + *mtu_int = 0; + if (!mtu) return TRUE; diff --git a/cli/src/settings.c b/cli/src/settings.c index 0fc708b352..876393f4fd 100644 --- a/cli/src/settings.c +++ b/cli/src/settings.c @@ -29,6 +29,7 @@ #include "utils.h" #include "common.h" #include "settings.h" +#include "nm-glib-compat.h" /* Forward declarations */ static char *wep_key_type_to_string (NMWepKeyType type); diff --git a/cli/src/utils.c b/cli/src/utils.c index 9b513f5a08..d6f804ca49 100644 --- a/cli/src/utils.c +++ b/cli/src/utils.c @@ -700,9 +700,9 @@ parse_output_fields (const char *fields_str, break; } } + if (found) + break; } - if (found) - break; } if (found) { /* Add index to array, and field name (or NULL) to group_fields array */ diff --git a/include/nm-glib-compat.h b/include/nm-glib-compat.h index cfaddb7d31..81d80f7c5b 100644 --- a/include/nm-glib-compat.h +++ b/include/nm-glib-compat.h @@ -27,8 +27,25 @@ #include #include + +#ifdef __clang__ + +#undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS +#undef G_GNUC_END_IGNORE_DEPRECATIONS + +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") + +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic pop") + +#endif + + #include "nm-gvaluearray-compat.h" + #if !GLIB_CHECK_VERSION(2,34,0) static inline void g_type_ensure (GType type) diff --git a/include/nm-gvaluearray-compat.h b/include/nm-gvaluearray-compat.h index e26ce37174..0fb4bd6e94 100644 --- a/include/nm-gvaluearray-compat.h +++ b/include/nm-gvaluearray-compat.h @@ -23,6 +23,8 @@ #include +#include "nm-glib-compat.h" + #define g_value_array_get_type() \ G_GNUC_EXTENSION ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c index 38911a43b4..c91060fb05 100644 --- a/libnm-glib/nm-remote-connection.c +++ b/libnm-glib/nm-remote-connection.c @@ -70,13 +70,13 @@ typedef struct RemoteCall RemoteCall; typedef void (*RemoteCallFetchResultCb) (RemoteCall *call, DBusGProxyCall *proxy_call, GError *error); -typedef struct RemoteCall { +struct RemoteCall { NMRemoteConnection *self; DBusGProxyCall *call; RemoteCallFetchResultCb fetch_result_cb; GFunc callback; gpointer user_data; -} RemoteCall; +}; typedef struct { DBusGConnection *bus; diff --git a/libnm-glib/tests/test-remote-settings-client.c b/libnm-glib/tests/test-remote-settings-client.c index a13e8311cb..12501ee361 100644 --- a/libnm-glib/tests/test-remote-settings-client.c +++ b/libnm-glib/tests/test-remote-settings-client.c @@ -49,7 +49,7 @@ cleanup (void) #define test_assert(condition) \ do { \ - gboolean _condition = ( condition ); \ + gboolean _condition = !!( condition ); \ \ if (G_UNLIKELY (!_condition)) { \ cleanup (); \ @@ -70,6 +70,7 @@ add_cb (NMRemoteSettings *s, *((gboolean *) user_data) = TRUE; remote = connection; + g_object_add_weak_pointer (G_OBJECT (connection), (void **) &remote); } #define TEST_CON_ID "blahblahblah" @@ -186,6 +187,9 @@ test_make_invisible (void) } while ((done == FALSE) && (now - start < 5)); test_assert (done == TRUE); + g_assert (remote); + g_signal_handlers_disconnect_by_func (remote, G_CALLBACK (invis_removed_cb), &done); + /* Ensure NMRemoteSettings no longer has the connection */ list = nm_remote_settings_list_connections (settings); for (iter = list; iter; iter = g_slist_next (iter)) { @@ -196,6 +200,7 @@ test_make_invisible (void) } /* And ensure the invisible connection no longer has any settings */ + g_assert (remote); nm_connection_for_each_setting_value (NM_CONNECTION (remote), invis_has_settings_cb, &has_settings); @@ -251,8 +256,11 @@ test_make_visible (void) } while ((new == NULL) && (now - start < 5)); /* Ensure the new connection is the same as the one we made visible again */ + test_assert (new); test_assert (new == remote); + g_signal_handlers_disconnect_by_func (settings, G_CALLBACK (vis_new_connection_cb), &new); + /* Ensure NMRemoteSettings has the connection */ list = nm_remote_settings_list_connections (settings); for (iter = list; iter; iter = g_slist_next (iter)) { @@ -309,6 +317,8 @@ test_remove_connection (void) test_assert (g_slist_length (list) > 0); connection = NM_REMOTE_CONNECTION (list->data); + g_assert (connection); + g_assert (remote == connection); path = g_strdup (nm_connection_get_path (NM_CONNECTION (connection))); g_signal_connect (connection, "removed", G_CALLBACK (removed_cb), &done); @@ -328,6 +338,8 @@ test_remove_connection (void) } while ((done == FALSE) && (now - start < 5)); test_assert (done == TRUE); + g_assert (!remote); + /* Ensure NMRemoteSettings no longer has the connection */ list = nm_remote_settings_list_connections (settings); for (iter = list; iter; iter = g_slist_next (iter)) { diff --git a/libnm-util/nm-setting-8021x.c b/libnm-util/nm-setting-8021x.c index d85b87b891..162b623049 100644 --- a/libnm-util/nm-setting-8021x.c +++ b/libnm-util/nm-setting-8021x.c @@ -92,6 +92,11 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_802_1X) #define NM_SETTING_802_1X_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_802_1X, NMSetting8021xPrivate)) +G_STATIC_ASSERT ( (NM_SETTING_802_1X_CK_FORMAT_UNKNOWN == (NMSetting8021xCKFormat) NM_CRYPTO_FILE_FORMAT_UNKNOWN) ); +G_STATIC_ASSERT ( (NM_SETTING_802_1X_CK_FORMAT_X509 == (NMSetting8021xCKFormat) NM_CRYPTO_FILE_FORMAT_X509) ); +G_STATIC_ASSERT ( (NM_SETTING_802_1X_CK_FORMAT_RAW_KEY == (NMSetting8021xCKFormat) NM_CRYPTO_FILE_FORMAT_RAW_KEY) ); +G_STATIC_ASSERT ( (NM_SETTING_802_1X_CK_FORMAT_PKCS12 == (NMSetting8021xCKFormat) NM_CRYPTO_FILE_FORMAT_PKCS12) ); + typedef struct { GSList *eap; /* GSList of strings */ char *identity; @@ -1824,7 +1829,7 @@ nm_setting_802_1x_set_private_key (NMSetting8021x *setting, g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD); if (out_format) - *out_format = format; + *out_format = (NMSetting8021xCKFormat) format; return priv->private_key != NULL; } @@ -2135,7 +2140,7 @@ nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting, g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD); if (out_format) - *out_format = format; + *out_format = (NMSetting8021xCKFormat) format; return priv->phase2_private_key != NULL; } diff --git a/libnm-util/nm-value-transforms.c b/libnm-util/nm-value-transforms.c index f92596dc60..18c2012eaf 100644 --- a/libnm-util/nm-value-transforms.c +++ b/libnm-util/nm-value-transforms.c @@ -115,7 +115,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/m4/compiler_warnings.m4 b/m4/compiler_warnings.m4 index 357ff0e7e0..0512ba1e0a 100644 --- a/m4/compiler_warnings.m4 +++ b/m4/compiler_warnings.m4 @@ -7,6 +7,23 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then AC_MSG_RESULT(yes) CFLAGS="-Wall -std=gnu89 $CFLAGS" + dnl clang only warns about unknown warnings, unless + dnl called with "-Werror=unknown-warning-option" + dnl Test if the compiler supports that, and if it does + dnl attach it to the CFLAGS. + SAVE_CFLAGS="$CFLAGS" + EXTRA_CFLAGS="-Werror=unknown-warning-option" + CFLAGS="$SAVE_CFLAGS $EXTRA_CFLAGS" + AC_TRY_COMPILE([], [], + has_option=yes, + has_option=no,) + if test $has_option = no; then + EXTRA_CFLAGS= + fi + CFLAGS="$SAVE_CFLAGS" + unset has_option + unset SAVE_CFLAGS + for option in -Wshadow -Wmissing-declarations -Wmissing-prototypes \ -Wdeclaration-after-statement -Wformat-security \ -Wfloat-equal -Wno-unused-parameter -Wno-sign-compare \ @@ -15,19 +32,22 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then -Wpointer-arith -Winit-self \ -Wmissing-include-dirs -Waggregate-return; do SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $option" + CFLAGS="$CFLAGS $EXTRA_CFLAGS $option" AC_MSG_CHECKING([whether gcc understands $option]) AC_TRY_COMPILE([], [], has_option=yes, has_option=no,) if test $has_option = no; then CFLAGS="$SAVE_CFLAGS" + else + CFLAGS="$SAVE_CFLAGS $option" fi AC_MSG_RESULT($has_option) unset has_option unset SAVE_CFLAGS done unset option + unset EXTRA_CFLAGS if test "x$set_more_warnings" = xerror; then CFLAGS="$CFLAGS -Werror" fi diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 0aaa344f91..7854364138 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -1208,5 +1208,6 @@ fail: else nm_log_err (LOGD_CORE, "Failed asserting path component: \"%s\"", name); g_error ("FATAL: Failed asserting path component: %s", name ? name : "(null)"); + g_assert_not_reached (); } diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index f4a90c7473..d0d31189a3 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -1234,7 +1234,7 @@ dcb_state (NMDevice *device, gboolean timeout) if (!dcb_enable (device)) { dcb_carrier_cleanup (device); nm_device_state_changed (device, - NM_ACT_STAGE_RETURN_FAILURE, + NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED); } } @@ -1258,7 +1258,7 @@ dcb_state (NMDevice *device, gboolean timeout) if (!dcb_configure (device)) { dcb_carrier_cleanup (device); nm_device_state_changed (device, - NM_ACT_STAGE_RETURN_FAILURE, + NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED); } } diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 4788a604db..291f03f619 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -366,7 +366,7 @@ static const char *state_table[] = { static const char * queued_state_to_string (NMDeviceState state) { - if (state >= 0 && state < G_N_ELEMENTS (state_table)) + if ((gsize) state < G_N_ELEMENTS (state_table)) return state_table[state]; return state_table[NM_DEVICE_STATE_UNKNOWN]; } @@ -442,7 +442,7 @@ static const char *reason_table[] = { static const char * reason_to_string (NMDeviceStateReason reason) { - if (reason >= 0 && reason < G_N_ELEMENTS (reason_table)) + if ((gsize) reason < G_N_ELEMENTS (reason_table)) return reason_table[reason]; return reason_table[NM_DEVICE_STATE_REASON_UNKNOWN]; } diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 85214a7005..09b525e408 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -189,7 +189,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) /* FIXME: VPN stuff here is a bug; but we can't really change API now... */ nm_device_state_changed (NM_DEVICE (priv->companion), NM_DEVICE_STATE_DISCONNECTED, - NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED); + NM_DEVICE_STATE_REASON_USER_REQUESTED); nm_log_info (LOGD_OLPC, "(%s): companion %s disconnected", nm_device_get_iface (dev), nm_device_get_iface (priv->companion)); @@ -315,7 +315,7 @@ companion_state_changed_cb (NMDeviceWifi *companion, /* FIXME: VPN stuff here is a bug; but we can't really change API now... */ nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_DISCONNECTED, - NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED); + NM_DEVICE_STATE_REASON_USER_REQUESTED); } static gboolean diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index fd3b4a3691..40428e27a9 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -126,7 +126,7 @@ static const char *state_table[] = { const char * nm_modem_state_to_string (NMModemState state) { - if (state >= 0 && state < G_N_ELEMENTS (state_table)) + if ((gsize) state < G_N_ELEMENTS (state_table)) return state_table[state]; return NULL; } diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c index 03c11c74d4..1f186f3256 100644 --- a/src/dhcp-manager/nm-dhcp-client.c +++ b/src/dhcp-manager/nm-dhcp-client.c @@ -607,7 +607,7 @@ static const char *state_table[] = { static const char * state_to_string (NMDHCPState state) { - if (state >= 0 && state < G_N_ELEMENTS (state_table)) + if ((gsize) state < G_N_ELEMENTS (state_table)) return state_table[state]; return NULL; } diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c index a1552ac246..e68906f38d 100644 --- a/src/dns-manager/nm-dns-manager.c +++ b/src/dns-manager/nm-dns-manager.c @@ -35,6 +35,7 @@ #include #include +#include "nm-utils.h" #include "nm-dns-manager.h" #include "nm-ip4-config.h" #include "nm-ip6-config.h" @@ -130,12 +131,8 @@ merge_one_ip4_config (NMResolvConfData *rc, NMIP4Config *src) num = nm_ip4_config_get_num_nameservers (src); for (i = 0; i < num; i++) { - guint32 addr; - char buf[INET_ADDRSTRLEN]; - - addr = nm_ip4_config_get_nameserver (src, i); - if (inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN) > 0) - add_string_item (rc->nameservers, buf); + add_string_item (rc->nameservers, + nm_utils_inet4_ntop (nm_ip4_config_get_nameserver (src, i), NULL)); } num = nm_ip4_config_get_num_domains (src); @@ -161,12 +158,8 @@ merge_one_ip4_config (NMResolvConfData *rc, NMIP4Config *src) /* NIS stuff */ num = nm_ip4_config_get_num_nis_servers (src); for (i = 0; i < num; i++) { - guint32 addr; - char buf[INET_ADDRSTRLEN]; - - addr = nm_ip4_config_get_nis_server (src, i); - if (inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN) > 0) - add_string_item (rc->nis_servers, buf); + add_string_item (rc->nis_servers, + nm_utils_inet4_ntop (nm_ip4_config_get_nis_server (src, i), NULL)); } if (nm_ip4_config_get_nis_domain (src)) { @@ -187,25 +180,21 @@ merge_one_ip6_config (NMResolvConfData *rc, NMIP6Config *src) num = nm_ip6_config_get_num_nameservers (src); for (i = 0; i < num; i++) { const struct in6_addr *addr; - char buf[INET6_ADDRSTRLEN]; - char *tmp; + char buf[NM_UTILS_INET_ADDRSTRLEN + 50]; addr = nm_ip6_config_get_nameserver (src, i); /* inet_ntop is probably supposed to do this for us, but it doesn't */ - if (IN6_IS_ADDR_V4MAPPED (addr)) { - if (inet_ntop (AF_INET, &(addr->s6_addr32[3]), buf, INET_ADDRSTRLEN) > 0) - add_string_item (rc->nameservers, buf); - } else { - if (inet_ntop (AF_INET6, addr, buf, INET6_ADDRSTRLEN) > 0) { - if (iface && IN6_IS_ADDR_LINKLOCAL (addr)) { - tmp = g_strdup_printf ("%s%%%s", buf, iface); - add_string_item (rc->nameservers, tmp); - g_free (tmp); - } else - add_string_item (rc->nameservers, buf); + if (IN6_IS_ADDR_V4MAPPED (addr)) + nm_utils_inet4_ntop (addr->s6_addr32[3], buf); + else { + nm_utils_inet6_ntop (addr, buf); + if (iface && IN6_IS_ADDR_LINKLOCAL (addr)) { + g_strlcat (buf, "%", sizeof (buf)); + g_strlcat (buf, iface, sizeof (buf)); } } + add_string_item (rc->nameservers, buf); } num = nm_ip6_config_get_num_domains (src); diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index c18132760c..d6c0a44ca9 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1723,15 +1723,14 @@ add_object (NMPlatform *platform, struct nl_object *obj) /* Decreases the reference count if @obj for convenience */ static gboolean -delete_object (NMPlatform *platform, struct nl_object *obj, gboolean do_refresh_object) +delete_object (NMPlatform *platform, struct nl_object *object, gboolean do_refresh_object) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); - auto_nl_object struct nl_object *obj_cleanup = obj; - struct nl_object *object = obj; int object_type; int nle; + gboolean result = FALSE; - object_type = object_type_from_nl_object (obj); + object_type = object_type_from_nl_object (object); g_return_val_if_fail (object_type != OBJECT_TYPE_UNKNOWN, FALSE); switch (object_type) { @@ -1774,14 +1773,18 @@ delete_object (NMPlatform *platform, struct nl_object *obj, gboolean do_refresh_ goto DEFAULT; DEFAULT: default: - error ("Netlink error deleting %s: %s (%d)", to_string_object (platform, obj), nl_geterror (nle), nle); - return FALSE; + error ("Netlink error deleting %s: %s (%d)", to_string_object (platform, object), nl_geterror (nle), nle); + goto out; } if (do_refresh_object) refresh_object (platform, object, TRUE, NM_PLATFORM_REASON_INTERNAL); - return TRUE; + result = TRUE; + +out: + nl_object_put (object); + return result; } static void diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c index ea8bd0e3b3..f505c2d26a 100644 --- a/src/platform/tests/platform.c +++ b/src/platform/tests/platform.c @@ -532,6 +532,9 @@ parse_ip_address (int family, char *str, gpointer address, int *plen) { char *endptr; + if (plen) + *plen = 0; + if (plen) { char *ptr = strchr (str, '/'); if (ptr) { diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index a3f757c2e7..37ba8f4ac8 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -130,6 +130,7 @@ software_add (NMLinkType link_type, const char *name) default: g_error ("Link type %d unhandled.", link_type); } + g_assert_not_reached (); } static void @@ -188,12 +189,12 @@ test_slave (int master, int type, SignalData *master_changed) /* Older team versions (e.g. Fedora 17) have a bug that team master stays * IFF_LOWER_UP even if its slave is down. Double check it with iproute2 and if * `ip link` also claims master to be up, accept it. */ - char *stdout = NULL; + char *stdout_str = NULL; - nmtst_spawn_sync (NULL, &stdout, NULL, 0, "/sbin/ip", "link", "show", "dev", nm_platform_link_get_name (master)); + nmtst_spawn_sync (NULL, &stdout_str, NULL, 0, "/sbin/ip", "link", "show", "dev", nm_platform_link_get_name (master)); - g_assert (strstr (stdout, "LOWER_UP")); - g_free (stdout); + g_assert (strstr (stdout_str, "LOWER_UP")); + g_free (stdout_str); } else g_assert_not_reached (); } diff --git a/src/platform/wifi/wifi-utils-nl80211.c b/src/platform/wifi/wifi-utils-nl80211.c index 25ebd1b3ce..b2de4e29be 100644 --- a/src/platform/wifi/wifi-utils-nl80211.c +++ b/src/platform/wifi/wifi-utils-nl80211.c @@ -679,11 +679,20 @@ static int nl80211_wiphy_info_handler (struct nl_msg *msg, void *arg) static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = { [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 }, [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG }, +#ifdef NL80211_FREQUENCY_ATTR_NO_IR + [NL80211_FREQUENCY_ATTR_NO_IR] = { .type = NLA_FLAG }, +#else [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG }, [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG }, +#endif [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG }, [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 }, }; +#ifdef NL80211_FREQUENCY_ATTR_NO_IR + G_STATIC_ASSERT (NL80211_FREQUENCY_ATTR_PASSIVE_SCAN == NL80211_FREQUENCY_ATTR_NO_IR && NL80211_FREQUENCY_ATTR_NO_IBSS == NL80211_FREQUENCY_ATTR_NO_IR); +#else + G_STATIC_ASSERT (NL80211_FREQUENCY_ATTR_PASSIVE_SCAN != NL80211_FREQUENCY_ATTR_NO_IBSS); +#endif if (nla_parse (tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen (gnlh, 0), NULL) < 0) diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 7a616707e1..0a8b521a19 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/ifcfg-rh/utils.c b/src/settings/plugins/ifcfg-rh/utils.c index 8318a65dae..8ec7c0a131 100644 --- a/src/settings/plugins/ifcfg-rh/utils.c +++ b/src/settings/plugins/ifcfg-rh/utils.c @@ -37,7 +37,7 @@ char * utils_single_quote_string (const char *str) { - static const char const drop_chars[] = "\r\n"; /* drop CR and LF */ + static const char *drop_chars = "\r\n"; /* drop CR and LF */ static const char escape_char = '\\'; /* escape char is backslash */ static const char quote_char = '\''; /* quote char is single quote */ size_t i, slen, j = 0; diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index 60af599bf1..acb19705c1 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -2502,7 +2502,6 @@ error: static char * escape_id (const char *id) { - static const char const as_dash[] = "\\][|/=()!"; char *escaped = g_strdup (id); char *p = escaped; @@ -2510,7 +2509,7 @@ escape_id (const char *id) while (*p) { if (*p == ' ') *p = '_'; - else if (strchr (as_dash, *p)) + else if (strchr ("\\][|/=()!", *p)) *p = '-'; p++; } 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 11c03f0dbe..f3fea2bca8 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -66,7 +66,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); diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index d66dcfdb73..b9f204ce2e 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -173,7 +173,7 @@ _state_to_nm_vpn_state (VpnState state) case STATE_FAILED: return NM_VPN_CONNECTION_STATE_FAILED; default: - return STATE_UNKNOWN; + return NM_VPN_CONNECTION_STATE_UNKNOWN; } } @@ -662,7 +662,7 @@ static const char *state_table[] = { static const char * vpn_state_to_string (VpnState state) { - if (state >= 0 && state < G_N_ELEMENTS (state_table)) + if ((gsize) state < G_N_ELEMENTS (state_table)) return state_table[state]; return "unknown"; } diff --git a/tui/newt/nmt-newt-utils.c b/tui/newt/nmt-newt-utils.c index 68d8c449e5..70a65a8489 100644 --- a/tui/newt/nmt-newt-utils.c +++ b/tui/newt/nmt-newt-utils.c @@ -30,6 +30,7 @@ #include +#include "nm-glib-compat.h" #include "nmt-newt-utils.h" static void