Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH] mips: vdso: fix uninitialized warning for genvdso
@ 2026-11-11  2:46 Michael C. Pratt
  2026-12-05 11:08 ` Thomas Bogendoerfer
  0 siblings, 1 reply; 2+ messages in thread
From: Michael C. Pratt @ 2026-11-11  2:46 UTC (permalink / raw)
  To: linux-mips
  Cc: Michael C. Pratt, linux-kernel, Thomas Bogendoerfer,
	Greg Kroah-Hartman

On older versions of GCC such as GCC 10.2.1,
it is possible that a "maybe-uninitialized" warning is triggered
for the pointer variables in the header's inline functions
when all warnings are enabled.

Resolve this warning by initializing all the pointers to NULL.

Signed-off-by: Michael C. Pratt <mcpratt@pm.me>
---
 arch/mips/vdso/genvdso.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/mips/vdso/genvdso.h b/arch/mips/vdso/genvdso.h
index 9bfb874038b0..112f51e2e546 100644
--- a/arch/mips/vdso/genvdso.h
+++ b/arch/mips/vdso/genvdso.h
@@ -7,9 +7,9 @@
 static inline bool FUNC(patch_vdso)(const char *path, void *vdso)
 {
 	const ELF(Ehdr) *ehdr = vdso;
-	void *shdrs;
-	ELF(Shdr) *shdr;
-	char *shstrtab, *name;
+	void *shdrs = NULL;
+	ELF(Shdr) *shdr = NULL;
+	char *shstrtab = NULL, *name = NULL;
 	uint16_t sh_count, sh_entsize, i;
 
 	shdrs = vdso + FUNC(swap_uint)(ehdr->e_shoff);
@@ -58,10 +58,10 @@ static inline bool FUNC(patch_vdso)(const char *path, void *vdso)
 static inline bool FUNC(get_symbols)(const char *path, void *vdso)
 {
 	const ELF(Ehdr) *ehdr = vdso;
-	void *shdrs, *symtab;
-	ELF(Shdr) *shdr;
-	const ELF(Sym) *sym;
-	char *strtab, *name;
+	void *shdrs = NULL, *symtab = NULL;
+	ELF(Shdr) *shdr = NULL;
+	const ELF(Sym) *sym = NULL;
+	char *strtab = NULL, *name = NULL;
 	uint16_t sh_count, sh_entsize, st_count, st_entsize, i, j;
 	uint64_t offset;
 	uint32_t flags;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mips: vdso: fix uninitialized warning for genvdso
  2026-11-11  2:46 [PATCH] mips: vdso: fix uninitialized warning for genvdso Michael C. Pratt
@ 2026-12-05 11:08 ` Thomas Bogendoerfer
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Bogendoerfer @ 2026-12-05 11:08 UTC (permalink / raw)
  To: Michael C. Pratt; +Cc: linux-mips, linux-kernel, Greg Kroah-Hartman

On Wed, Nov 11, 2026 at 02:46:05AM +0000, Michael C. Pratt wrote:
> On older versions of GCC such as GCC 10.2.1,
> it is possible that a "maybe-uninitialized" warning is triggered
> for the pointer variables in the header's inline functions
> when all warnings are enabled.
> 
> Resolve this warning by initializing all the pointers to NULL.
> 
> Signed-off-by: Michael C. Pratt <mcpratt@pm.me>
> ---
>  arch/mips/vdso/genvdso.h | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/mips/vdso/genvdso.h b/arch/mips/vdso/genvdso.h
> index 9bfb874038b0..112f51e2e546 100644
> --- a/arch/mips/vdso/genvdso.h
> +++ b/arch/mips/vdso/genvdso.h
> @@ -7,9 +7,9 @@
>  static inline bool FUNC(patch_vdso)(const char *path, void *vdso)
>  {
>  	const ELF(Ehdr) *ehdr = vdso;
> -	void *shdrs;
> -	ELF(Shdr) *shdr;
> -	char *shstrtab, *name;
> +	void *shdrs = NULL;
> +	ELF(Shdr) *shdr = NULL;
> +	char *shstrtab = NULL, *name = NULL;
>  	uint16_t sh_count, sh_entsize, i;
>  
>  	shdrs = vdso + FUNC(swap_uint)(ehdr->e_shoff);

I don't see why the compiler thinks any of them are uninitialized.

> @@ -58,10 +58,10 @@ static inline bool FUNC(patch_vdso)(const char *path, void *vdso)
>  static inline bool FUNC(get_symbols)(const char *path, void *vdso)
>  {
>  	const ELF(Ehdr) *ehdr = vdso;
> -	void *shdrs, *symtab;
> -	ELF(Shdr) *shdr;
> -	const ELF(Sym) *sym;
> -	char *strtab, *name;
> +	void *shdrs = NULL, *symtab = NULL;
> +	ELF(Shdr) *shdr = NULL;
> +	const ELF(Sym) *sym = NULL;
> +	char *strtab = NULL, *name = NULL;
>  	uint16_t sh_count, sh_entsize, st_count, st_entsize, i, j;
>  	uint64_t offset;
>  	uint32_t flags;

following line is

	shdrs = vdso + FUNC(swap_uint)(ehdr->e_shoff);

so shdrs is always initialized. But with sh_count the others might be
uninitialized, but then the function exists early.

I'm not going to apply this as the code is correct, IMHO.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-05 11:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11  2:46 [PATCH] mips: vdso: fix uninitialized warning for genvdso Michael C. Pratt
2026-12-05 11:08 ` Thomas Bogendoerfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox