Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1316253

Re: [PATCH 3/3] defxx: fix build warning

From "Maciej W. Rozycki" <macro@linux-mips.org>
Newsgroups linux.kernel
Subject Re: [PATCH 3/3] defxx: fix build warning
Date 2016-01-25 08:10 +0100
Message-ID <qUJrH-o2-5@gated-at.bofh.it> (permalink)
References <qUIFk-8fT-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, 25 Jan 2016, Sudip Mukherjee wrote:

> We are getting many build warning about:
> 'bar_start' may be used uninitialized
> and
> 'bar_len' may be used uninitialized
> 
> They are not actually uninitialized as dfx_get_bars() will initialize
> them properly. But still lets have them initialized just to satisfy the
> compiler.

 Which compiler/version is that?

> diff --git a/drivers/net/fddi/defxx.c b/drivers/net/fddi/defxx.c
> index 7f975a2..4113535 100644
> --- a/drivers/net/fddi/defxx.c
> +++ b/drivers/net/fddi/defxx.c
> @@ -533,8 +533,8 @@ static int dfx_register(struct device *bdev)
>  	const char *print_name = dev_name(bdev);
>  	struct net_device *dev;
>  	DFX_board_t	  *bp;			/* board pointer */
> -	resource_size_t bar_start[3];		/* pointers to ports */
> -	resource_size_t bar_len[3];		/* resource length */
> +	resource_size_t bar_start[3] = {0, 0, 0};	/* pointers to ports */
> +	resource_size_t bar_len[3] = {0, 0, 0};		/* resource length */
>  	int alloc_size;				/* total buffer size used */
>  	struct resource *region;
>  	int err = 0;

 Just setting the first element will do, the rest will then be implicitly 
zeroed, following the semantics of initialisers in C.  So just do:

	resource_size_t bar_start[3] = {0};	/* pointers to ports */
	resource_size_t bar_len[3] = {0};	/* resource length */

for brevity and to save formatting.

> @@ -3697,8 +3697,8 @@ static void dfx_unregister(struct device *bdev)
>  	int dfx_bus_pci = dev_is_pci(bdev);
>  	int dfx_bus_tc = DFX_BUS_TC(bdev);
>  	int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
> -	resource_size_t bar_start[3];		/* pointers to ports */
> -	resource_size_t bar_len[3];		/* resource lengths */
> +	resource_size_t bar_start[3] = {0, 0, 0};	/* pointers to ports */
> +	resource_size_t bar_len[3] = {0, 0, 0};		/* resource lengths */
>  	int		alloc_size;		/* total buffer size used */
>  
>  	unregister_netdev(dev);

 Likewise here.  Please resend with the update requested and I'll ack it.

 Thanks for your submission!

  Maciej

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 3/3] defxx: fix build warning Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2016-01-25 07:20 +0100
  Re: [PATCH 3/3] defxx: fix build warning "Maciej W. Rozycki" <macro@linux-mips.org> - 2016-01-25 08:10 +0100

csiph-web