diff mbox series

lib: utils: fdt_fixup: Fix compile error

Message ID 20230219101559.708444-1-wxjstz@126.com
State Superseded
Headers show
Series lib: utils: fdt_fixup: Fix compile error | expand

Commit Message

Xiang W Feb. 19, 2023, 10:15 a.m. UTC
When building with GCC-10 or older versions, it throws the following
error:

 CC-DEP    platform/generic/lib/utils/fdt/fdt_fixup.dep
 CC        platform/generic/lib/utils/fdt/fdt_fixup.o
lib/utils/fdt/fdt_fixup.c: In function 'fdt_reserved_memory_fixup':
lib/utils/fdt/fdt_fixup.c:376:2: error: label at end of compound statement
  376 |  next_entry:
      |  ^~~~~~~~~~

Thus move the label "next_entry" to the beginning of the for loop.
Fixed issue#288 [1]

[1]: https://github.com/riscv-software-src/opensbi/issues/288

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Signed-off-by: Xiang W <wxjstz@126.com>
---
 lib/utils/fdt/fdt_fixup.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Andreas Schwab Feb. 19, 2023, 10:20 a.m. UTC | #1
On Feb 19 2023, Xiang W wrote:

> Thus move the label "next_entry" to the beginning of the for loop.

This is not what the patch does.
Xiang W Feb. 19, 2023, 12:41 p.m. UTC | #2
在 2023-02-19星期日的 11:20 +0100,Andreas Schwab写道:
> On Feb 19 2023, Xiang W wrote:
> 
> > Thus move the label "next_entry" to the beginning of the for loop.
> 
> This is not what the patch does.
new patch at https://lists.infradead.org/pipermail/opensbi/2023-February/004494.html

Regards,
Xiang
>
diff mbox series

Patch

diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
index 619e4f5..e23517d 100644
--- a/lib/utils/fdt/fdt_fixup.c
+++ b/lib/utils/fdt/fdt_fixup.c
@@ -361,19 +361,22 @@  int fdt_reserved_memory_fixup(void *fdt)
 			return SBI_ENOSPC;
 		}
 
+		int overlap = 0;
 		addr = reg->base;
 		for (j = 0; j < i; j++) {
 			if (addr == filtered_base[j]
 			    && filtered_order[j] < reg->order) {
+				overlap = 1;
 				filtered_order[j] = reg->order;
-				goto next_entry;
+				break;
 			}
 		}
 
-		filtered_base[i] = reg->base;
-		filtered_order[i] = reg->order;
-		i++;
-	next_entry:
+		if (!overlap) {
+			filtered_base[i] = reg->base;
+			filtered_order[i] = reg->order;
+			i++;
+		}
 	}
 
 	for (j = 0; j < i; j++) {