summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-02-03 22:49:37 +0100
committerThomas Haller <thaller@redhat.com>2022-02-09 19:13:02 +0100
commit6208a1bb8456f5649bf7ffb8d8d20cbe62bfd4aa (patch)
tree904a76781d97a1e534cde4fdce1b8f89498525b2
parentf65747f6e9edc4a6d01d8825e6c6bc3da284c6b9 (diff)
libnm: reorder fields in NMIPAddress/NMIPRoute struct
Order the fields by their size, to minimize the alignment gaps. I guess, that doesn't matter because the alignment of the heap allocation is larger than what we can safe here. Still, there is on reason to do it any other way. Also, it's not possible via API to set family/prefix to values outside their range, so an 8bit integer is always sufficient. And we don't want that invariant to change. We don't ever want to allow the caller to set values that are clearly invalid, and will assert against that early (g_return()). Point is, we can do this and there is no danger of future problems. And even if we will support larger values, it's all an implementation detail anyway.
-rw-r--r--src/libnm-core-impl/nm-setting-ip-config.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libnm-core-impl/nm-setting-ip-config.c b/src/libnm-core-impl/nm-setting-ip-config.c
index 0dc0a58610..1dbf92537e 100644
--- a/src/libnm-core-impl/nm-setting-ip-config.c
+++ b/src/libnm-core-impl/nm-setting-ip-config.c
@@ -169,9 +169,10 @@ G_DEFINE_BOXED_TYPE(NMIPAddress, nm_ip_address, nm_ip_address_dup, nm_ip_address
struct NMIPAddress {
guint refcount;
- char *address;
- int prefix, family;
+ gint8 family;
+ guint8 prefix;
+ char *address;
GHashTable *attributes;
};
@@ -608,13 +609,14 @@ G_DEFINE_BOXED_TYPE(NMIPRoute, nm_ip_route, nm_ip_route_dup, nm_ip_route_unref)
struct NMIPRoute {
guint refcount;
- int family;
- char *dest;
- guint prefix;
- char *next_hop;
- gint64 metric;
+ gint8 family;
+ guint8 prefix;
+ char *dest;
+ char *next_hop;
GHashTable *attributes;
+
+ gint64 metric;
};
/**