mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 18:00:10 +01:00
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().
This commit is contained in:
parent
438855e915
commit
47d8bee113
1 changed files with 3 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue