From: Ben Pfaff Date: Fri, 6 Nov 2009 20:24:44 +0000 (-0800) Subject: json: Make json_equal() compare objects correctly. X-Git-Tag: v1.0.0~259^2~520 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=6e57173fab673b66870b3e181f09542da0d61587;p=sliver-openvswitch.git json: Make json_equal() compare objects correctly. The previous code checked only that JSON objects have members with the same names. This commit makes json_equal() also check that like-named members have the same values. --- diff --git a/lib/json.c b/lib/json.c index dfd6b8453..cdcfba598 100644 --- a/lib/json.c +++ b/lib/json.c @@ -500,14 +500,15 @@ json_hash(const struct json *json, size_t basis) static bool json_equal_object(const struct shash *a, const struct shash *b) { - struct shash_node *node; + struct shash_node *a_node; if (shash_count(a) != shash_count(b)) { return false; } - SHASH_FOR_EACH (node, a) { - if (!shash_find(b, node->name)) { + SHASH_FOR_EACH (a_node, a) { + struct shash_node *b_node = shash_find(b, a_node->name); + if (!b_node || !json_equal(a_node->data, b_node->data)) { return false; } }