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 10:58:15 +0200
commit63c228271d8726d0ec65bf25534ff4977ce43550 (patch)
tree85c645d745dc8da6f8e69376a89d6f3e6565e9a8
parente076788790752dec56c00998e5f9e06a571a69ae (diff)
downloadNetworkManager-63c228271d8726d0ec65bf25534ff4977ce43550.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 8105ae20f2..5937393fcf 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.
@@ -18090,7 +18093,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,