lib: utils: fdt_fixup: Fix compile error
PATCH 1/1 lib: utils: fdt_fixup: Fix compile error
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.olib/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
--- lib/utils/fdt/fdt_fixup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/utils/fdt/fdt_fixup.c +1 -1
@@ -345,6 +345,7 @@ int fdt_reserved_memory_fixup(void *fdt) i =0 ;sbi_domain_for_each_memregion (dom, reg) { +next_entry:/* Ignore MMIO or READABLE or WRITABLE or EXECUTABLE regions */ if (reg->flags &SBI_DOMAIN_MEMREGION_MMIO )continue ;
@@ -373,7 +374,6 @@ int fdt_reserved_memory_fixup(void *fdt) filtered_base[i] = reg->base; filtered_order[i] = reg->order; i++; - next_entry: }for (j =0 ; j < i; j++) {
Signature · 1 line
2.34.1
PATCH 1/1 lib: utils: fdt_fixup: Fix compile error
Quoted 1 line · Yu Chien Peter Lin
Thus move the label "
next_entry" to the beginning of the for loop.
This changes the semantics, because jumping to the top of the loop skips the update expression.
Signature · 3 lines
Andreas Schwab, schwab at linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
PATCH 1/1 lib: utils: fdt_fixup: Fix compile error
Quoted 11 lines · Andreas Schwab
Quoted 1 line · Yu Chien Peter Lin
Thus move the label "
next_entry" to the beginning of the for loop.This changes the semantics, because jumping to the top of the loop skips the update expression.
Signature · 3 lines
Andreas Schwab, schwab at linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Hi Andreas,
Thanks for pointing this out!
Hi Xiang,
I've set the patch state to superseded,
Could you send your fix?
Thanks
Peter Lin
PATCH 1/1 lib: utils: fdt_fixup: Fix compile error
In reply to Yu Chien Peter Lin? 2023-02-19???? 14:33 +0800?Yu Chien Peter Lin???
Quoted 33 lines
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.olib/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 <[email protected]>---
?lib/utils/fdt/fdt_fixup.c | 2 +-
?1 file changed, 1 insertion(+), 1 deletion(-)lib/utils/fdt/fdt_fixup.c +0
-0@@ -345,6 +345,7 @@ int fdt_reserved_memory_fixup(void *fdt)?
????????i = 0;
????????sbi_domain_for_each_memregion(dom, reg) {
+next_entry:
????????????????/* Ignore MMIO or READABLE or WRITABLE or EXECUTABLE regions */ ????????????????if (reg->flags&SBI_DOMAIN_MEMREGION_MMIO) ????????????????????????continue;
lib/utils/fdt/fdt_fixup.c int fdt_reserved_memory_fixup(void *fdt) · line 377
Quoted 5 lines
lib/utils/fdt/fdt_fixup.c +0
-1@@ -373,7 +374,6 @@ int fdt_reserved_memory_fixup(void *fdt) ????????????????filtered_base[i] = reg->base; ????????????????filtered_order[i] = reg->order; ????????????????i++; -???????next_entry: ????????}
I suggest to remove goto.
lib/utils/fdt/fdt_fixup.c +8 -5
@@ -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++) {
Regards,
Xiang
Quoted 6 lines
?
????????for (j = 0; j < i; j++) {Signature · 1 line
2.34.1