* [PATCH] lib: utils: fdt_fixup: Fix compile error
@ 2023-02-19 6:33 Yu Chien Peter Lin
2023-02-19 9:11 ` Andreas Schwab
2023-02-19 9:28 ` Xiang W
0 siblings, 2 replies; 7+ messages in thread
From: Yu Chien Peter Lin @ 2023-02-19 6:33 UTC (permalink / raw)
To: opensbi
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>
---
lib/utils/fdt/fdt_fixup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
index 619e4f5..9dac98a 100644
--- a/lib/utils/fdt/fdt_fixup.c
+++ b/lib/utils/fdt/fdt_fixup.c
@@ -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++) {
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] lib: utils: fdt_fixup: Fix compile error
2023-02-19 6:33 Yu Chien Peter Lin
@ 2023-02-19 9:11 ` Andreas Schwab
2023-02-19 17:44 ` Yu-Chien Peter Lin
2023-02-19 9:28 ` Xiang W
1 sibling, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2023-02-19 9:11 UTC (permalink / raw)
To: opensbi
On Feb 19 2023, Yu Chien Peter Lin wrote:
> 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.
--
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."
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] lib: utils: fdt_fixup: Fix compile error
2023-02-19 6:33 Yu Chien Peter Lin
2023-02-19 9:11 ` Andreas Schwab
@ 2023-02-19 9:28 ` Xiang W
1 sibling, 0 replies; 7+ messages in thread
From: Xiang W @ 2023-02-19 9:28 UTC (permalink / raw)
To: opensbi
? 2023-02-19???? 14:33 +0800?Yu Chien Peter Lin???
> 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>
> ---
> ?lib/utils/fdt/fdt_fixup.c | 2 +-
> ?1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
> index 619e4f5..9dac98a 100644
> --- a/lib/utils/fdt/fdt_fixup.c
> +++ b/lib/utils/fdt/fdt_fixup.c
> @@ -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:
> ????????}
I suggest to remove goto.
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++) {
Regards,
Xiang
> ?
> ????????for (j = 0; j < i; j++) {
> --
> 2.34.1
>
>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] lib: utils: fdt_fixup: Fix compile error
@ 2023-02-19 10:15 Xiang W
2023-02-19 10:20 ` Andreas Schwab
0 siblings, 1 reply; 7+ messages in thread
From: Xiang W @ 2023-02-19 10:15 UTC (permalink / raw)
To: opensbi
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(-)
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++) {
--
2.39.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] lib: utils: fdt_fixup: Fix compile error
2023-02-19 10:15 [PATCH] lib: utils: fdt_fixup: Fix compile error Xiang W
@ 2023-02-19 10:20 ` Andreas Schwab
2023-02-19 12:41 ` Xiang W
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2023-02-19 10:20 UTC (permalink / raw)
To: opensbi
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.
--
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."
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] lib: utils: fdt_fixup: Fix compile error
2023-02-19 10:20 ` Andreas Schwab
@ 2023-02-19 12:41 ` Xiang W
0 siblings, 0 replies; 7+ messages in thread
From: Xiang W @ 2023-02-19 12:41 UTC (permalink / raw)
To: opensbi
? 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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] lib: utils: fdt_fixup: Fix compile error
2023-02-19 9:11 ` Andreas Schwab
@ 2023-02-19 17:44 ` Yu-Chien Peter Lin
0 siblings, 0 replies; 7+ messages in thread
From: Yu-Chien Peter Lin @ 2023-02-19 17:44 UTC (permalink / raw)
To: opensbi
On Sun, Feb 19, 2023 at 10:11:09AM +0100, Andreas Schwab wrote:
> On Feb 19 2023, Yu Chien Peter Lin wrote:
>
> > 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.
>
> --
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-02-19 17:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-19 10:15 [PATCH] lib: utils: fdt_fixup: Fix compile error Xiang W
2023-02-19 10:20 ` Andreas Schwab
2023-02-19 12:41 ` Xiang W
-- strict thread matches above, loose matches on Subject: below --
2023-02-19 6:33 Yu Chien Peter Lin
2023-02-19 9:11 ` Andreas Schwab
2023-02-19 17:44 ` Yu-Chien Peter Lin
2023-02-19 9:28 ` Xiang W
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.