All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3.17-rc5 ] scripts/sortextable: Suppress warning: ‘relocs_size’ may be used uninitialized
@ 2014-09-16 18:49 tim.gardner
  2014-09-18  8:20 ` Jamie Iles
  0 siblings, 1 reply; 2+ messages in thread
From: tim.gardner @ 2014-09-16 18:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Tim Gardner, Andrew Morton, Jamie Iles

From: Tim Gardner <tim.gardner@canonical.com>

In file included from scripts/sortextable.c:194:0:
scripts/sortextable.c: In function ‘main’:
scripts/sortextable.h:176:3: warning: ‘relocs_size’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   memset(relocs, 0, relocs_size);
   ^
scripts/sortextable.h:106:6: note: ‘relocs_size’ was declared here
  int relocs_size;
      ^
In file included from scripts/sortextable.c:192:0:
scripts/sortextable.h:176:3: warning: ‘relocs_size’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   memset(relocs, 0, relocs_size);
   ^
scripts/sortextable.h:106:6: note: ‘relocs_size’ was declared here
  int relocs_size;
      ^

gcc 4.9.1

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jamie Iles <jamie.iles@oracle.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---

Is gcc 4.9 dumber then 4.8 ? gcc 4.8 doesn't produce this warning.

 scripts/sortextable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/sortextable.h b/scripts/sortextable.h
index 8fac3fd..ba87004 100644
--- a/scripts/sortextable.h
+++ b/scripts/sortextable.h
@@ -103,7 +103,7 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
 	Elf_Sym *sort_needed_sym;
 	Elf_Shdr *sort_needed_sec;
 	Elf_Rel *relocs = NULL;
-	int relocs_size;
+	int relocs_size = 0;
 	uint32_t *sort_done_location;
 	const char *secstrtab;
 	const char *strtab;
-- 
2.1.0


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

* Re: [PATCH 3.17-rc5 ] scripts/sortextable: Suppress warning: ‘relocs_size’ may be used uninitialized
  2014-09-16 18:49 [PATCH 3.17-rc5 ] scripts/sortextable: Suppress warning: ‘relocs_size’ may be used uninitialized tim.gardner
@ 2014-09-18  8:20 ` Jamie Iles
  0 siblings, 0 replies; 2+ messages in thread
From: Jamie Iles @ 2014-09-18  8:20 UTC (permalink / raw)
  To: tim.gardner; +Cc: linux-kernel, Andrew Morton, Jamie Iles

Hi Tim,

On Tue, Sep 16, 2014 at 12:49:22PM -0600, tim.gardner@canonical.com wrote:
> From: Tim Gardner <tim.gardner@canonical.com>
> 
> In file included from scripts/sortextable.c:194:0:
> scripts/sortextable.c: In function ‘main’:
> scripts/sortextable.h:176:3: warning: ‘relocs_size’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>    memset(relocs, 0, relocs_size);
>    ^
> scripts/sortextable.h:106:6: note: ‘relocs_size’ was declared here
>   int relocs_size;
>       ^
> In file included from scripts/sortextable.c:192:0:
> scripts/sortextable.h:176:3: warning: ‘relocs_size’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>    memset(relocs, 0, relocs_size);
>    ^
> scripts/sortextable.h:106:6: note: ‘relocs_size’ was declared here
>   int relocs_size;
>       ^
> 
> gcc 4.9.1
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Jamie Iles <jamie.iles@oracle.com>

Reviewed-by: Jamie Iles <jamie.iles@oracle.com>

> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
> 
> Is gcc 4.9 dumber then 4.8 ? gcc 4.8 doesn't produce this warning.

It's an odd one - I don't see how relocs_size can be uninitialized when 
relocs is non-null.  Your fix looks fine to me though.

Jamie

>  scripts/sortextable.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/sortextable.h b/scripts/sortextable.h
> index 8fac3fd..ba87004 100644
> --- a/scripts/sortextable.h
> +++ b/scripts/sortextable.h
> @@ -103,7 +103,7 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
>  	Elf_Sym *sort_needed_sym;
>  	Elf_Shdr *sort_needed_sec;
>  	Elf_Rel *relocs = NULL;
> -	int relocs_size;
> +	int relocs_size = 0;
>  	uint32_t *sort_done_location;
>  	const char *secstrtab;
>  	const char *strtab;
> -- 
> 2.1.0
> 

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

end of thread, other threads:[~2014-09-18  8:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-16 18:49 [PATCH 3.17-rc5 ] scripts/sortextable: Suppress warning: ‘relocs_size’ may be used uninitialized tim.gardner
2014-09-18  8:20 ` Jamie Iles

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.