libfdt: Fix -Wextra -Wpedantic warnings
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
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
@@ -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
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.
Signed-off-by Bingwu Zhang <[email protected]>
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@@ -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
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
Re: [PATCH 1/2] libfdt: Suppress a unused parameter warning in overlay_fixup_one_phandle
In reply to David GibsonQuoted 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
PATCH 2/2 libfdt: Remove extra semi-colons outside functions
In reply to Bingwu ZhangFrom: 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
@@ -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
@@ -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
David Gibson
AppliedRe: [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.
Signed-off-by Bingwu Zhang <[email protected]>
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@@ -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@@ -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