Skip to contentSkip to conversation

libfdt: Fix -Wextra -Wpedantic warnings

PATCH Applied Bingwu Zhang 2 participants 7 messages Nov 16, 2024 – Nov 18, 2024

lore
Share & tools
lore
#0 lore raw

cover libfdt: Fix -Wextra -Wpedantic warnings

From: Bingwu Zhang <[email protected]>

This fixes several warning when compiling with CFLAGS='-Wall -Wextra
-Wpedantic'. When using together with '-Werror' flag, these warnings becomes fatal errors that fails the build.

Both of the original errors and fixes for them are tested with GCC 13
and clang 18.

Bingwu Zhang (2):
libfdt: Suppress a unused parameter warning in
overlay_fixup_one_phandle
libfdt: Remove extra semi-colons outside functions

 libfdt/fdt_overlay.c |  3 ++-
 libfdt/libfdt.h      | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 11 deletions(-)

base-commit: 2d10aa2afe35527728db30b35ec491ecb6959e5c

Signature · 1 line
2.47.0
#1 lore raw

PATCH 1/2 libfdt: Suppress a unused parameter warning in overlay_fixup_one_phandle

From: Bingwu Zhang <[email protected]>

When compiling with -Wall -Wextra, the unused fdt parameter becomes a warning. With -Werror, it becomes an error that fails the build.

Thanks to Icenowy Zheng for pointing out the solution.

---
 libfdt/fdt_overlay.c | 1 +
 1 file changed, 1 insertion(+)
libfdt/fdt_overlay.c +1 -0
index 28b667ffc490..f9be13865807 100644
@@ -334,6 +334,7 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 				     const char *name, uint32_t name_len,
 				     int poffset, uint32_t phandle)
 {
+	(void)fdt;
 	fdt32_t phandle_prop;
 	int fixup_off;
 
Signature · 1 line
2.47.0
#2 lore raw

Re: [PATCH 1/2] libfdt: Suppress a unused parameter warning in overlay_fixup_one_phandle

Quoted 8 lines · Bingwu Zhang

From: Bingwu Zhang <[email protected]>

When compiling with -Wall -Wextra, the unused fdt parameter becomes a warning. With -Werror, it becomes an error that fails the build.

Thanks to Icenowy Zheng for pointing out the solution.

AFAICT this parameter is *really* unused, it's not just the compiled being confused. So I'd prefer to actually remove the parameter, rather than suppress the warning.

Quoted 16 lines
---
 libfdt/fdt_overlay.c | 1 +
 1 file changed, 1 insertion(+)
libfdt/fdt_overlay.c +1 -0
index 28b667ffc490..f9be13865807 100644
@@ -334,6 +334,7 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 				     const char *name, uint32_t name_len,
 				     int poffset, uint32_t phandle)
 {
+	(void)fdt;
 	fdt32_t phandle_prop;
 	int fixup_off;
 
Signature · 4 lines
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson
author
#3 lore raw

Re: [PATCH 1/2] libfdt: Suppress a unused parameter warning in overlay_fixup_one_phandle

Quoted 3 lines

AFAICT this parameter is *really* unused, it's not just the compiled being confused. So I'd prefer to actually remove the parameter, rather than suppress the warning.

Acknowledged, I will make a v2 patch this weekend, as soon as I am back at home.

--
xtex @ Nov 18, 2024 18:15 UTC

author
#4 lore raw

Re: [PATCH 1/2] libfdt: Suppress a unused parameter warning in overlay_fixup_one_phandle

In reply to David Gibson
Quoted 3 lines

AFAICT this parameter is *really* unused, it's not just the compiled being confused. So I'd prefer to actually remove the parameter, rather than suppress the warning.

Acknowledged, I will make a v2 patch this weekend, as soon as I am back at home.

--
xtex @ Nov 18, 2024 18:15 UTC

#5 lore raw

PATCH 2/2 libfdt: Remove extra semi-colons outside functions

In reply to Bingwu Zhang

From: Bingwu Zhang <[email protected]>

When compiling with -Werror -Wpedantic, both GCC and Clang fails, saying that these semi-colons are redundant, so remove them.

---
 libfdt/fdt_overlay.c |  2 +-
 libfdt/libfdt.h      | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)
libfdt/fdt_overlay.c +1 -1
index f9be13865807..1b098e61c270 100644
@@ -352,7 +352,7 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 						   name, name_len, poffset,
 						   &phandle_prop,
 						   sizeof(phandle_prop));
-};
+}
 
 /**
  * overlay_fixup_phandle - Set an overlay phandle to the base one
libfdt/libfdt.h +10 -10
index 96782bc57b84..2e182ea3314d 100644
@@ -263,16 +263,16 @@ int fdt_next_subnode(const void *fdt, int offset);
 		struct fdt_header *fdth = (struct fdt_header *)fdt; \
 		fdth->name = cpu_to_fdt32(val); \
 	}
-fdt_set_hdr_(magic);
-fdt_set_hdr_(totalsize);
-fdt_set_hdr_(off_dt_struct);
-fdt_set_hdr_(off_dt_strings);
-fdt_set_hdr_(off_mem_rsvmap);
-fdt_set_hdr_(version);
-fdt_set_hdr_(last_comp_version);
-fdt_set_hdr_(boot_cpuid_phys);
-fdt_set_hdr_(size_dt_strings);
-fdt_set_hdr_(size_dt_struct);
+fdt_set_hdr_(magic)
+fdt_set_hdr_(totalsize)
+fdt_set_hdr_(off_dt_struct)
+fdt_set_hdr_(off_dt_strings)
+fdt_set_hdr_(off_mem_rsvmap)
+fdt_set_hdr_(version)
+fdt_set_hdr_(last_comp_version)
+fdt_set_hdr_(boot_cpuid_phys)
+fdt_set_hdr_(size_dt_strings)
+fdt_set_hdr_(size_dt_struct)
 #undef fdt_set_hdr_
 
 /**
Signature · 1 line
2.47.0
Applied
#6 lore raw

Re: [PATCH 2/2] libfdt: Remove extra semi-colons outside functions

Quoted 6 lines · Bingwu Zhang

From: Bingwu Zhang <[email protected]>

When compiling with -Werror -Wpedantic, both GCC and Clang fails, saying that these semi-colons are redundant, so remove them.

Applied, thanks.

Quoted 49 lines
---
 libfdt/fdt_overlay.c |  2 +-
 libfdt/libfdt.h      | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)
libfdt/fdt_overlay.c +1 -1
index f9be13865807..1b098e61c270 100644
@@ -352,7 +352,7 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 						   name, name_len, poffset,
 						   &phandle_prop,
 						   sizeof(phandle_prop));
-};
+}
 
 /**
  * overlay_fixup_phandle - Set an overlay phandle to the base one
libfdt/libfdt.h +10 -10
index 96782bc57b84..2e182ea3314d 100644
@@ -263,16 +263,16 @@ int fdt_next_subnode(const void *fdt, int offset);
 		struct fdt_header *fdth = (struct fdt_header *)fdt; \
 		fdth->name = cpu_to_fdt32(val); \
 	}
-fdt_set_hdr_(magic);
-fdt_set_hdr_(totalsize);
-fdt_set_hdr_(off_dt_struct);
-fdt_set_hdr_(off_dt_strings);
-fdt_set_hdr_(off_mem_rsvmap);
-fdt_set_hdr_(version);
-fdt_set_hdr_(last_comp_version);
-fdt_set_hdr_(boot_cpuid_phys);
-fdt_set_hdr_(size_dt_strings);
-fdt_set_hdr_(size_dt_struct);
+fdt_set_hdr_(magic)
+fdt_set_hdr_(totalsize)
+fdt_set_hdr_(off_dt_struct)
+fdt_set_hdr_(off_dt_strings)
+fdt_set_hdr_(off_mem_rsvmap)
+fdt_set_hdr_(version)
+fdt_set_hdr_(last_comp_version)
+fdt_set_hdr_(boot_cpuid_phys)
+fdt_set_hdr_(size_dt_strings)
+fdt_set_hdr_(size_dt_struct)
 #undef fdt_set_hdr_
 
 /**
Signature · 4 lines
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson