]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
object: fix attribute comparison
authorPatrick McHardy <kaber@trash.net>
Wed, 7 Apr 2010 17:15:40 +0000 (19:15 +0200)
committerThomas Graf <tgraf@suug.ch>
Mon, 19 Apr 2010 10:51:24 +0000 (12:51 +0200)
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>
include/netlink/object-api.h

index 5877c00d61a6c19a932dcfe8daaee88fb5c3ba21..b3337f00ba313380870fd40c909b4000c748542d 100644 (file)
@@ -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