Commit 6c2ffcd2 authored by Thomas Haller's avatar Thomas Haller Committed by Lubomir Rintel

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().

(cherry picked from commit 47d8bee1)
parent 8b1f68ec
......@@ -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;
......
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