summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-09-10 13:20:29 +0200
committerThomas Haller <thaller@redhat.com>2020-09-11 16:18:38 +0200
commitee447cbb527eb0acc97827a7d2298f69b1d0791d (patch)
treeda886868699c7cb69f52f91d7cb63b9a709eacf9
parentb6dc2e15d23abe4b6dc2468ca25ee785ee4f0438 (diff)
downloadNetworkManager-ee447cbb527eb0acc97827a7d2298f69b1d0791d.tar.gz
device: mark NMDevicePrivate.sys_iface_state as const
It's important to find place in code where are field (state) gets mutated. Make sys_iface_state field const, but add a mutable alias via a union. You can now grep for places that change the field.
-rw-r--r--src/devices/nm-device.c11
-rw-r--r--src/devices/nm-device.h2
2 files changed, 8 insertions, 5 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index e19109336a..8490ffc95a 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -442,6 +442,11 @@ typedef struct _NMDevicePrivate {
NML3ConfigMergeFlags l3config_merge_flags_x[2];
};
+ union {
+ const NMDeviceSysIfaceState sys_iface_state;
+ NMDeviceSysIfaceState sys_iface_state_;
+ };
+
bool carrier:1;
bool ignore_carrier:1;
@@ -453,8 +458,6 @@ typedef struct _NMDevicePrivate {
bool default_route_metric_penalty_ip4_has:1;
bool default_route_metric_penalty_ip6_has:1;
- NMDeviceSysIfaceState sys_iface_state:2;
-
bool v4_route_table_initialized:1;
bool v6_route_table_initialized:1;
@@ -1423,7 +1426,7 @@ nm_device_sys_iface_state_set (NMDevice *self,
_LOGT (LOGD_DEVICE, "sys-iface-state: %s -> %s",
_sys_iface_state_to_str (priv->sys_iface_state),
_sys_iface_state_to_str (sys_iface_state));
- priv->sys_iface_state = sys_iface_state;
+ priv->sys_iface_state_ = sys_iface_state;
}
/* this function only sets a flag, no immediate actions are initiated.
@@ -18091,7 +18094,7 @@ nm_device_init (NMDevice *self)
priv->unmanaged_mask = priv->unmanaged_flags;
priv->available_connections = g_hash_table_new_full (nm_direct_hash, NULL, g_object_unref, NULL);
priv->ip6_saved_properties = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, g_free);
- priv->sys_iface_state = NM_DEVICE_SYS_IFACE_STATE_EXTERNAL;
+ priv->sys_iface_state_ = NM_DEVICE_SYS_IFACE_STATE_EXTERNAL;
priv->v4_commit_first_time = TRUE;
priv->v6_commit_first_time = TRUE;
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 36cae7a3aa..d9ac0022f8 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -16,7 +16,7 @@
#include "nm-rfkill-manager.h"
#include "NetworkManagerUtils.h"
-typedef enum {
+typedef enum _nm_packed {
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_ASSUME,
NM_DEVICE_SYS_IFACE_STATE_MANAGED,