Skip to contentSkip to conversation

dtc: Improve portability

PATCH In review Phil Elwell 2 participants 2 messages Oct 21, 2014 – Oct 22, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dtc: Improve portability

1) Remove the double parentheses around two comparisons in checks.c. The OSX LLVM-based C compiler warns about them.
2) Put an explicit "=" in the TN() macro, in accordance with c99.

---
 checks.c  | 4 ++--
 fdtdump.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
checks.c +2 -2
index 47eda65..3bf0fa4 100644
@@ -624,11 +624,11 @@ static void check_avoid_default_addr_size(struct check *c,
 struct node *dt,
        if (!reg && !ranges)
                return;
 
-       if ((node->parent->addr_cells == -1))
+       if (node->parent->addr_cells == -1)
                FAIL(c, "Relying on default #address-cells value for %s",
                     node->fullpath);
 
-       if ((node->parent->size_cells == -1))
+       if (node->parent->size_cells == -1)
                FAIL(c, "Relying on default #size-cells value for %s",
                     node->fullpath);

}

fdtdump.c +1 -1
index a29aa5e..95a6a20 100644
@@ -22,7 +22,7 @@
 static const char *tagname(uint32_t tag)
 {
        static const char * const names[] = {
-#define TN(t) [t] #t
+#define TN(t) [t] = #t
                TN(FDT_BEGIN_NODE),
                TN(FDT_END_NODE),
                TN(FDT_PROP),

--
1.9.1

From c80e173a0936091d6278cb6ced3710f485bc067a Mon Sep 17 00:00:00 2001
From: Phil Elwell <[email protected]>
Date: Fri, 17 Oct 2014 23:22:11 +0100
Subject: [PATCH] Improve portability

1) Remove the double parentheses around two comparisons in checks.c. The OSX LLVM-based C compiler warns about them.
2) Put an explicit "=" in the TN() macro, in accordance with c99.

---
 checks.c  | 4 ++--
 fdtdump.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
checks.c +2 -2
index 47eda65..3bf0fa4 100644
@@ -624,11 +624,11 @@ static void check_avoid_default_addr_size(struct check *c, struct node *dt,
 	if (!reg && !ranges)
 		return;
 
-	if ((node->parent->addr_cells == -1))
+	if (node->parent->addr_cells == -1)
 		FAIL(c, "Relying on default #address-cells value for %s",
 		     node->fullpath);
 
-	if ((node->parent->size_cells == -1))
+	if (node->parent->size_cells == -1)
 		FAIL(c, "Relying on default #size-cells value for %s",
 		     node->fullpath);
 }
fdtdump.c +1 -1
index a29aa5e..95a6a20 100644
@@ -22,7 +22,7 @@
 static const char *tagname(uint32_t tag)
 {
 	static const char * const names[] = {
-#define TN(t) [t] #t
+#define TN(t) [t] = #t
 		TN(FDT_BEGIN_NODE),
 		TN(FDT_END_NODE),
 		TN(FDT_PROP),
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 2 lines · Phil Elwell

1) Remove the double parentheses around two comparisons in checks.c. The OSX LLVM-based C compiler warns about them.

That seems a weird thing to warn for, but the result is cleaner anyway, so I'm happy to apply it.

Quoted 1 line

2) Put an explicit "=" in the TN() macro, in accordance with c99.

I'm slightly astonished that ever worked.

I need a Signed-off-by line, then I can apply.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson