Commit 79e3b2a8 authored by Thomas Haller's avatar Thomas Haller Committed by Lubomir Rintel

platform: use bool bitfields in NMPlatformActionMirred structure

Arguably, the structure is used inside a union with another (larger)
struct, hence no memory is saved.

In fact, it may well be slower performance wise to access a boolean bitfield
than a gboolean (int).

Still, boolean fields in structures should be bool:1 bitfields for
consistency.

(cherry picked from commit 36d6aa3b)
parent c17fa82b
......@@ -6577,11 +6577,12 @@ nm_platform_tfilter_hash_update (const NMPlatformTfilter *obj, NMHashState *h)
nm_hash_update_strarr (h, obj->action.simple.sdata);
} else if (nm_streq (obj->action.kind, NM_PLATFORM_ACTION_KIND_MIRRED)) {
nm_hash_update_vals (h,
obj->action.mirred.ingress,
obj->action.mirred.egress,
obj->action.mirred.mirror,
obj->action.mirred.redirect,
obj->action.mirred.ifindex);
obj->action.mirred.ifindex,
NM_HASH_COMBINE_BOOLS (guint8,
obj->action.mirred.ingress,
obj->action.mirred.egress,
obj->action.mirred.mirror,
obj->action.mirred.redirect));
}
}
}
......@@ -6602,11 +6603,11 @@ nm_platform_tfilter_cmp (const NMPlatformTfilter *a, const NMPlatformTfilter *b)
if (nm_streq (a->action.kind, NM_PLATFORM_ACTION_KIND_SIMPLE)) {
NM_CMP_FIELD_STR (a, b, action.simple.sdata);
} else if (nm_streq (a->action.kind, NM_PLATFORM_ACTION_KIND_MIRRED)) {
NM_CMP_FIELD (a, b, action.mirred.ingress);
NM_CMP_FIELD (a, b, action.mirred.egress);
NM_CMP_FIELD (a, b, action.mirred.mirror);
NM_CMP_FIELD (a, b, action.mirred.redirect);
NM_CMP_FIELD (a, b, action.mirred.ifindex);
NM_CMP_FIELD_UNSAFE (a, b, action.mirred.ingress);
NM_CMP_FIELD_UNSAFE (a, b, action.mirred.egress);
NM_CMP_FIELD_UNSAFE (a, b, action.mirred.mirror);
NM_CMP_FIELD_UNSAFE (a, b, action.mirred.redirect);
}
}
......
......@@ -641,11 +641,11 @@ typedef struct {
} NMPlatformActionSimple;
typedef struct {
gboolean egress;
gboolean ingress;
gboolean mirror;
gboolean redirect;
int ifindex;
bool egress:1;
bool ingress:1;
bool mirror:1;
bool redirect:1;
} NMPlatformActionMirred;
typedef struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment