mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] commands: of_diff: don't mix tabs and spaces for indentation
@ 2021-12-09 10:57 Ahmad Fatoum
  2021-12-13 22:16 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2021-12-09 10:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Nodes are indented with spaces, while properties are indented with tabs,
leading to discrepancies when the indentation doesn't start at a tab
stop, like when using of_diff:

chosen {
+ 	barebox-version = "barebox-2021.06.0-20210716-2";
+ 	reset-source = "POR";
+ 	reset-source-instance = <0x0>;
+        subnode {

Fix this by using spaces throughout.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/of/base.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 664a3a411eaf..06e37b0fca4a 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2011,12 +2011,7 @@ void of_print_nodes(struct device_node *node, int indent)
 
 static void __of_print_property(struct property *p, int indent)
 {
-	int i;
-
-	for (i = 0; i < indent; i++)
-		printf("\t");
-
-	printf("%s", p->name);
+	printf("%*s%s", indent * 8, "", p->name);
 	if (p->length) {
 		printf(" = ");
 		of_print_property(of_property_get_value(p), p->length);
@@ -2034,17 +2029,14 @@ void of_print_properties(struct device_node *node)
 
 static int __of_print_parents(struct device_node *node)
 {
-	int indent, i;
+	int indent;
 
 	if (!node->parent)
 		return 0;
 
 	indent = __of_print_parents(node->parent);
 
-	for (i = 0; i < indent; i++)
-		printf("\t");
-
-	printf("%s {\n", node->name);
+	printf("%*s%s {\n", indent * 8, "", node->name);
 
 	return indent + 1;
 }
@@ -2124,14 +2116,14 @@ void of_diff(struct device_node *a, struct device_node *b, int indent)
 			of_diff(ca, cb, indent + 1);
 		} else {
 			of_print_parents(a, &printed);
-			__of_print_nodes(ca, indent, "-");
+			__of_print_nodes(ca, indent, "- ");
 		}
 	}
 
 	for_each_child_of_node(b, cb) {
 		if (!of_get_child_by_name(a, cb->name)) {
 			of_print_parents(a, &printed);
-			__of_print_nodes(cb, indent, "+");
+			__of_print_nodes(cb, indent, "+ ");
 		}
 	}
 
-- 
2.30.2


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-13 22:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 10:57 [PATCH] commands: of_diff: don't mix tabs and spaces for indentation Ahmad Fatoum
2021-12-13 22:16 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox