From d36df06c24a44c09fb838816cae03f921986c6ff Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 11 Feb 2020 21:03:38 +0100 Subject: shared: don't require callback argument to nm_dbus_connection_call_set() It's fine to call propery-set without caring about the result. --- shared/nm-glib-aux/nm-dbus-aux.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/shared/nm-glib-aux/nm-dbus-aux.c b/shared/nm-glib-aux/nm-dbus-aux.c index 7c55b5a750..9cb0a7f091 100644 --- a/shared/nm-glib-aux/nm-dbus-aux.c +++ b/shared/nm-glib-aux/nm-dbus-aux.c @@ -111,8 +111,6 @@ void nm_dbus_connection_call_set (GDBusConnection *dbus_connection, NMDBusConnectionCallDefaultCb callback, gpointer user_data) { - nm_assert (callback); - g_dbus_connection_call (dbus_connection, bus_name, object_path, -- cgit v1.2.3 From 984e94f01d8e2febba79b0624cdb2576fe329cd7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 11 Feb 2020 21:06:02 +0100 Subject: supplicant: expose nm_supplicant_driver_to_string() helper function Will be useful later. --- src/supplicant/nm-supplicant-interface.c | 16 +++------------- src/supplicant/nm-supplicant-manager.c | 10 ++++++++++ src/supplicant/nm-supplicant-types.h | 3 +++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c index 4b6b4f6e1e..e25928c14d 100644 --- a/src/supplicant/nm-supplicant-interface.c +++ b/src/supplicant/nm-supplicant-interface.c @@ -1805,19 +1805,9 @@ on_wpas_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_d */ if (priv->dev != NULL) { - const char *driver_name = NULL; - - switch (priv->driver) { - case NM_SUPPLICANT_DRIVER_WIRELESS: - driver_name = NM_WPAS_DEFAULT_WIFI_DRIVER; - break; - case NM_SUPPLICANT_DRIVER_WIRED: - driver_name = "wired"; - break; - case NM_SUPPLICANT_DRIVER_MACSEC: - driver_name = "macsec_linux"; - break; - } + const char *driver_name; + + driver_name = nm_supplicant_driver_to_string (priv->driver); g_return_if_fail (driver_name); diff --git a/src/supplicant/nm-supplicant-manager.c b/src/supplicant/nm-supplicant-manager.c index 65b910cade..08bed98cf3 100644 --- a/src/supplicant/nm-supplicant-manager.c +++ b/src/supplicant/nm-supplicant-manager.c @@ -48,6 +48,16 @@ NM_CACHED_QUARK_FCN ("nm-supplicant-error-quark", nm_supplicant_error_quark) /*****************************************************************************/ +NM_UTILS_LOOKUP_STR_DEFINE (nm_supplicant_driver_to_string, NMSupplicantDriver, + NM_UTILS_LOOKUP_DEFAULT_WARN (NULL), + NM_UTILS_LOOKUP_ITEM (NM_SUPPLICANT_DRIVER_UNKNOWN, "???"), + NM_UTILS_LOOKUP_ITEM (NM_SUPPLICANT_DRIVER_WIRELESS, NM_WPAS_DEFAULT_WIFI_DRIVER), + NM_UTILS_LOOKUP_ITEM (NM_SUPPLICANT_DRIVER_WIRED, "wired"), + NM_UTILS_LOOKUP_ITEM (NM_SUPPLICANT_DRIVER_MACSEC, "macsec_linux"), +); + +/*****************************************************************************/ + static void _caps_set (NMSupplicantManagerPrivate *priv, NMSupplCapType type, diff --git a/src/supplicant/nm-supplicant-types.h b/src/supplicant/nm-supplicant-types.h index de0283b24a..17fbc0c009 100644 --- a/src/supplicant/nm-supplicant-types.h +++ b/src/supplicant/nm-supplicant-types.h @@ -127,11 +127,14 @@ typedef enum { } NMSupplicantError; typedef enum { + NM_SUPPLICANT_DRIVER_UNKNOWN, NM_SUPPLICANT_DRIVER_WIRELESS, NM_SUPPLICANT_DRIVER_WIRED, NM_SUPPLICANT_DRIVER_MACSEC, } NMSupplicantDriver; +const char *nm_supplicant_driver_to_string (NMSupplicantDriver driver); + #define NM_SUPPLICANT_ERROR (nm_supplicant_error_quark ()) GQuark nm_supplicant_error_quark (void); -- cgit v1.2.3 From 098c0d50927830c9d02b4abc8a63da31276fb46f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 12 Feb 2020 10:36:57 +0100 Subject: device: inline "struct Supplicant" to where it is used --- src/devices/nm-device-ethernet.c | 25 ++++++++++++------------- src/devices/nm-device-macsec.c | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index a87b772e8a..f6dc70d4eb 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -45,18 +45,6 @@ _LOG_DECLARE_SELF(NMDeviceEthernet); /*****************************************************************************/ -typedef struct Supplicant { - NMSupplicantManager *mgr; - NMSupplicantInterface *iface; - - /* signal handler ids */ - gulong iface_state_id; - gulong auth_state_id; - - /* Timeouts and idles */ - guint con_timeout_id; -} Supplicant; - typedef enum { DCB_WAIT_UNKNOWN = 0, /* Ensure carrier is up before enabling DCB */ @@ -75,7 +63,18 @@ typedef struct _NMDeviceEthernetPrivate { guint32 speed; gulong carrier_id; - Supplicant supplicant; + struct { + NMSupplicantManager *mgr; + NMSupplicantInterface *iface; + + /* signal handler ids */ + gulong iface_state_id; + gulong auth_state_id; + + /* Timeouts and idles */ + guint con_timeout_id; + } supplicant; + guint supplicant_timeout_id; /* s390 */ diff --git a/src/devices/nm-device-macsec.c b/src/devices/nm-device-macsec.c index dbb4ac8efe..b7c9e7728e 100644 --- a/src/devices/nm-device-macsec.c +++ b/src/devices/nm-device-macsec.c @@ -23,17 +23,6 @@ _LOG_DECLARE_SELF(NMDeviceMacsec); /*****************************************************************************/ -typedef struct Supplicant { - NMSupplicantManager *mgr; - NMSupplicantInterface *iface; - - /* signal handler ids */ - gulong iface_state_id; - - /* Timeouts and idles */ - guint con_timeout_id; -} Supplicant; - NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceMacsec, PROP_SCI, PROP_CIPHER_SUITE, @@ -53,7 +42,18 @@ typedef struct { NMPlatformLnkMacsec props; gulong parent_state_id; gulong parent_mtu_id; - Supplicant supplicant; + + struct { + NMSupplicantManager *mgr; + NMSupplicantInterface *iface; + + /* signal handler ids */ + gulong iface_state_id; + + /* Timeouts and idles */ + guint con_timeout_id; + } supplicant; + guint supplicant_timeout_id; NMActRequestGetSecretsCallId *macsec_secrets_id; } NMDeviceMacsecPrivate; -- cgit v1.2.3 From c23c2e2f942554fb6132c0a08db4f2090bd1cf1c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 12 Feb 2020 14:34:07 +0100 Subject: device: reorder fields in NMDeviceEthernetPrivate struct --- src/devices/nm-device-ethernet.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index f6dc70d4eb..9d29a0e228 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -60,6 +60,15 @@ typedef enum { } DcbWait; typedef struct _NMDeviceEthernetPrivate { + /* s390 */ + char * subchan1; + char * subchan2; + char * subchan3; + char * subchannels; /* Composite used for checking unmanaged specs */ + char ** subchannels_dbus; /* Array exported on D-Bus */ + char * s390_nettype; + GHashTable * s390_options; + guint32 speed; gulong carrier_id; @@ -77,15 +86,6 @@ typedef struct _NMDeviceEthernetPrivate { guint supplicant_timeout_id; - /* s390 */ - char * subchan1; - char * subchan2; - char * subchan3; - char * subchannels; /* Composite used for checking unmanaged specs */ - char ** subchannels_dbus; /* Array exported on D-Bus */ - char * s390_nettype; - GHashTable * s390_options; - NMActRequestGetSecretsCallId *wired_secrets_id; /* PPPoE */ -- cgit v1.2.3 From f0bc4aa525617b631fa30374322365b7e2b4460b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 12 Feb 2020 14:39:10 +0100 Subject: device: move supplicant_timeout_id into supplicant struct in NMDeviceEthernetPrivate The supplicant struct is there to group related variables. Move supplicant_timeout_id there. --- src/devices/nm-device-ethernet.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 9d29a0e228..bdb46844c6 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -82,9 +82,9 @@ typedef struct _NMDeviceEthernetPrivate { /* Timeouts and idles */ guint con_timeout_id; - } supplicant; - guint supplicant_timeout_id; + guint timeout_id; + } supplicant; NMActRequestGetSecretsCallId *wired_secrets_id; @@ -399,7 +399,7 @@ supplicant_interface_release (NMDeviceEthernet *self) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); - nm_clear_g_source (&priv->supplicant_timeout_id); + nm_clear_g_source (&priv->supplicant.timeout_id); nm_clear_g_source (&priv->supplicant.con_timeout_id); nm_clear_g_signal_handler (priv->supplicant.iface, &priv->supplicant.iface_state_id); nm_clear_g_signal_handler (priv->supplicant.iface, &priv->supplicant.auth_state_id); @@ -546,7 +546,7 @@ link_timeout_cb (gpointer user_data) NMConnection *applied_connection; const char *setting_name; - priv->supplicant_timeout_id = 0; + priv->supplicant.timeout_id = 0; req = nm_device_get_act_request (device); @@ -674,7 +674,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, } break; case NM_SUPPLICANT_INTERFACE_STATE_COMPLETED: - nm_clear_g_source (&priv->supplicant_timeout_id); + nm_clear_g_source (&priv->supplicant.timeout_id); nm_clear_g_source (&priv->supplicant.con_timeout_id); /* If this is the initial association during device activation, @@ -689,8 +689,8 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, case NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED: if ((devstate == NM_DEVICE_STATE_ACTIVATED) || nm_device_is_activating (device)) { /* Start the link timeout so we allow some time for reauthentication */ - if (!priv->supplicant_timeout_id) - priv->supplicant_timeout_id = g_timeout_add_seconds (15, link_timeout_cb, device); + if (!priv->supplicant.timeout_id) + priv->supplicant.timeout_id = g_timeout_add_seconds (15, link_timeout_cb, device); } break; case NM_SUPPLICANT_INTERFACE_STATE_DOWN: -- cgit v1.2.3