[PATCH v2 4/5] of: silence of_diff output for negative indents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Negative indents just led to strange behavior so far. Repurpose them to
mean that the caller is not interested in console output. This makes
them useful for negative tests (Sanity check that two different nodes
are indeed different).

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
v1 -> v2:
  - use silent variable instead of opencoding indent < 0 (Sascha)
---
 drivers/of/base.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 99be24254203..51984d7d8f61 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2082,11 +2082,14 @@ int of_diff(struct device_node *a, struct device_node *b, int indent)
 	struct property *ap, *bp;
 	struct device_node *ca, *cb;
 	int printed = 0, diff = 0;
+	bool silent = indent < 0;
 
 	list_for_each_entry(ap, &a->properties, list) {
 		bp = of_find_property(b, ap->name, NULL);
 		if (!bp) {
 			diff++;
+			if (silent)
+				continue;
 			of_print_parents(a, &printed);
 			printf("- ");
 			__of_print_property(ap, indent);
@@ -2095,6 +2098,8 @@ int of_diff(struct device_node *a, struct device_node *b, int indent)
 
 		if (ap->length != bp->length || memcmp(of_property_get_value(ap), of_property_get_value(bp), bp->length)) {
 			diff++;
+			if (silent)
+				continue;
 			of_print_parents(a, &printed);
 			printf("- ");
 			__of_print_property(ap, indent);
@@ -2107,6 +2112,8 @@ int of_diff(struct device_node *a, struct device_node *b, int indent)
 		ap = of_find_property(a, bp->name, NULL);
 		if (!ap) {
 			diff++;
+			if (silent)
+				continue;
 			of_print_parents(a, &printed);
 			printf("+ ");
 			__of_print_property(bp, indent);
@@ -2116,9 +2123,11 @@ int of_diff(struct device_node *a, struct device_node *b, int indent)
 	for_each_child_of_node(a, ca) {
 		cb = of_get_child_by_name(b, ca->name);
 		if (cb) {
-			diff += of_diff(ca, cb, indent + 1);
+			diff += of_diff(ca, cb, silent ? indent : indent + 1);
 		} else {
 			diff++;
+			if (silent)
+				continue;
 			of_print_parents(a, &printed);
 			__of_print_nodes(ca, indent, "- ");
 		}
@@ -2127,12 +2136,15 @@ int of_diff(struct device_node *a, struct device_node *b, int indent)
 	for_each_child_of_node(b, cb) {
 		if (!of_get_child_by_name(a, cb->name)) {
 			diff++;
+			if (silent)
+				continue;
 			of_print_parents(a, &printed);
 			__of_print_nodes(cb, indent, "+ ");
 		}
 	}
 
-	of_print_close(a, &printed);
+	if (!silent)
+		of_print_close(a, &printed);
 
 	return diff;
 }
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux