diff options
author | Patrick McHardy <kaber@trash.net> | 2010-04-07 17:15:40 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2010-04-19 10:51:24 (GMT) |
commit | b3096c4acfb63e27c87ae1a2f6d4f611d899c12d (patch) | |
tree | 3c6dcdd35471203d85334ecce813406e7928ce3d /include | |
parent | 3c28aa5dca309286ad9136c6d4742969b5dfde1d (diff) | |
download | libnl-b3096c4acfb63e27c87ae1a2f6d4f611d899c12d.zip libnl-b3096c4acfb63e27c87ae1a2f6d4f611d899c12d.tar.gz libnl-b3096c4acfb63e27c87ae1a2f6d4f611d899c12d.tar.bz2 |
object: fix attribute comparison
Currently two attributes are regarded as different if they are absent in
both objects to be compared. This is obviously incorrect, change to
regard objects as different if an attribute is only present on one of
them or if the attribute data differs.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/netlink/object-api.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/include/netlink/object-api.h b/include/netlink/object-api.h index 5877c00..b3337f0 100644 --- a/include/netlink/object-api.h +++ b/include/netlink/object-api.h @@ -198,7 +198,18 @@ extern "C" { * * @return True if the attribute is available, otherwise false is returned. */ -#define AVAILABLE(A, B, ATTR) (((A)->ce_mask & (B)->ce_mask) & (ATTR)) +#define AVAILABLE(A, B, ATTR) (((A)->ce_mask & (B)->ce_mask) & (ATTR)) + +/** + * Return true if attribute is available in only one of both objects + * @arg A an object + * @arg B another object + * @arg ATTR attribute bit + * + * @return True if the attribute is available in only one of both objects, + * otherwise false is returned. + */ +#define AVAILABLE_MISMATCH(A, B, ATTR) (((A)->ce_mask ^ (B)->ce_mask) & (ATTR)) /** * Return true if attributes mismatch @@ -215,7 +226,8 @@ extern "C" { * * @return True if the attribute mismatch, or false if they match. */ -#define ATTR_MISMATCH(A, B, ATTR, EXPR) (!AVAILABLE(A, B, ATTR) || (EXPR)) +#define ATTR_MISMATCH(A, B, ATTR, EXPR) (AVAILABLE_MISMATCH(A, B, ATTR) || \ + (AVAILABLE(A, B, ATTR) && (EXPR))) /** * Return attribute bit if attribute does not match |