Skip to contentSkip to conversation

lib: utils: fdt_fixup: Fix compile error

PATCH Superseded Xiang W 3 participants 3 messages Feb 19, 2023 – Feb 21, 2023

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Xiang W

author
#0 lore raw

PATCH v2 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.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:
      |  ^~~~~~~~~~

Remove the goto statement. Fixed issue#288 [1]

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

---
Changes in v2:
- Fix a comment issue raised by Andreas Schwab

 lib/utils/fdt/fdt_fixup.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
lib/utils/fdt/fdt_fixup.c +8 -5
index 619e4f5..e23517d 100644
@@ -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++) {
Signature · 1 line
2.39.1
#1 lore raw

PATCH v2 1/1 lib: utils: fdt_fixup: Fix compile error

Quoted 11 lines · Xiang W

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:
      |  ^~~~~~~~~~
Quoted 6 lines

Remove the goto statement. Fixed issue#288 [1]

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

Looks good to me.

Regards,
Anup

Quoted 47 lines

---
Changes in v2:
- Fix a comment issue raised by Andreas Schwab

 lib/utils/fdt/fdt_fixup.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
lib/utils/fdt/fdt_fixup.c +8 -6
index 619e4f5..e23517d 100644
@@ -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

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

#2 lore raw

PATCH v2 1/1 lib: utils: fdt_fixup: Fix compile error

In reply to Xiang W
Quoted 4 lines · Xiang W

When building with GCC-10 or older versions, it throws the following error:

Quoted 8 lines

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:
      |  ^~~~~~~~~~

Remove the goto statement. Fixed issue#288 [1]

nits: Use "Resolves" tag

Quoted 2 lines

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

So this becomes:

Resolves: https://github.com/riscv-software-src/opensbi/issues/288

Quoted 15 lines

---
Changes in v2:
- Fix a comment issue raised by Andreas Schwab

 lib/utils/fdt/fdt_fixup.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
lib/utils/fdt/fdt_fixup.c +0 -0
index 619e4f5..e23517d 100644

lib/utils/fdt/fdt_fixup.c int fdt_reserved_memory_fixup(void *fdt) · line 364

Quoted 4 lines
lib/utils/fdt/fdt_fixup.c +1 -0
@@ -361,19 +361,22 @@ int fdt_reserved_memory_fixup(void *fdt)
                        return SBI_ENOSPC;
                }
 
+               int overlap = 0;

bool overlap = false;

Quoted 24 lines
lib/utils/fdt/fdt_fixup.c +7 -6
                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++) {
--
Quoted 2 lines

2.39.1

Regards,
Bin