From 47d8bee1130c619a41fe64753d88d88012f9fb98 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 1 May 2019 08:10:47 +0200 Subject: [PATCH] platform: use NM_CMP_FIELD_UNSAFE() for comparing bitfield in nm_platform_qdisc_cmp() "NM_CMP_FIELD (a, b, fq_codel.ecn == TRUE)" is quite a hack as it relies on the implementation of the macro in a particular way. The problem is, that NM_CMP_FIELD() uses typeof() which cannot be used with bitfields. So, the nicer solution is to use NM_CMP_FIELD_UNSAFE() which exists exactly for bitfields (it's "unsafe", because it evaluates arguments more than once as it avoids the temporary variable with typeof()). Same with nm_hash_update_vals() which uses typeof() to avoid evaluating arguments more than once. But that again does not work with bitfields. The "proper" way is to use NM_HASH_COMBINE_BOOLS(). --- src/platform/nm-platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 6f23ddb589..f8cf0b8999 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -6480,7 +6480,8 @@ nm_platform_qdisc_hash_update (const NMPlatformQdisc *obj, NMHashState *h) obj->fq_codel.quantum, obj->fq_codel.ce_threshold, obj->fq_codel.memory, - obj->fq_codel.ecn == TRUE); + NM_HASH_COMBINE_BOOLS (guint8, + obj->fq_codel.ecn)); } } @@ -6503,7 +6504,7 @@ nm_platform_qdisc_cmp (const NMPlatformQdisc *a, const NMPlatformQdisc *b) NM_CMP_FIELD (a, b, fq_codel.quantum); NM_CMP_FIELD (a, b, fq_codel.ce_threshold); NM_CMP_FIELD (a, b, fq_codel.memory); - NM_CMP_FIELD (a, b, fq_codel.ecn == TRUE); + NM_CMP_FIELD_UNSAFE (a, b, fq_codel.ecn); } return 0;