Skip to contentSkip to conversation

lib: utils: fdt_fixup: Fix compile error

PATCH New Xiang W 3 participants 3 messages Feb 21, 2023 – Feb 27, 2023

lore
Share & tools
lore

Xiang W

author
#0 lore raw

PATCH v4 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.

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

---
Changes in v4:
- Continue to fix the comment in Changes v3

Changes in v3:
- Fix a comment issue raised by Bin Meng
- Changed the type of "overlap" from int to bool as suggested by Bin Meng

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 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
lib/utils/fdt/fdt_fixup.c +8 -5
index 619e4f5..c10179b 100644
@@ -361,19 +361,22 @@ int fdt_reserved_memory_fixup(void *fdt)
 			return SBI_ENOSPC;
 		}
 
+		bool overlap = false;
 		addr = reg->base;
 		for (j = 0; j < i; j++) {
 			if (addr == filtered_base[j]
 			    && filtered_order[j] < reg->order) {
+				overlap = true;
 				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 v4 1/1 lib: utils: fdt_fixup: Fix compile error

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

Remove the goto statement.

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

---
Changes in v4:
- Continue to fix the comment in Changes v3

Changes in v3:
- Fix a comment issue raised by Bin Meng
- Changed the type of "overlap" from int to bool as suggested by Bin Meng

Quoted 8 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 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
Applied
#2 lore raw

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

In reply to Xiang W
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 7 lines

Remove the goto statement.

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

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 51 lines

---
Changes in v4:
- Continue to fix the comment in Changes v3

Changes in v3:
- Fix a comment issue raised by Bin Meng
- Changed the type of "overlap" from int to bool as suggested by Bin Meng

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 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
lib/utils/fdt/fdt_fixup.c +8 -6
index 619e4f5..c10179b 100644
@@ -361,19 +361,22 @@ int fdt_reserved_memory_fixup(void *fdt)
                        return SBI_ENOSPC;
                }
 
+               bool overlap = false;
                addr = reg->base;
                for (j = 0; j < i; j++) {
                        if (addr == filtered_base[j]
                            && filtered_order[j] < reg->order) {
+                               overlap = true;
                                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