Re: [PATCH 5/5] staging: bcm: fix errors and warnings by checkpatch.pl in IPv6Protocol.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 20, 2012 at 10:15:57AM -0800, pradheep.sh@xxxxxxxxx wrote:
> -static UCHAR * GetNextIPV6ChainedHeader(UCHAR **ppucPayload,UCHAR *pucNextHeader,BOOLEAN *bParseDone,USHORT *pusPayloadLength)
> +static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload, UCHAR *pucNextHeader, BOOLEAN *bParseDone, USHORT *pusPayloadLength)
>  {
>  	UCHAR *pucRetHeaderPtr = NULL;
>  	UCHAR *pucPayloadPtr = NULL;
> -	USHORT  usNextHeaderOffset = 0 ;
> -    PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
> -
> -	if((NULL == ppucPayload) || (*pusPayloadLength == 0) || (*bParseDone))
> -	{
> +	USHORT  usNextHeaderOffset = 0;
> +	IPV6RoutingHeader *pstIpv6RoutingHeader = NULL;
> +	IPV6DestOptionsHeader *pstIpv6DestOptsHdr = NULL;
> +	IPV6AuthenticationHeader *pstIpv6AuthHdr = NULL;
> +	int nTotalOptions = 0;
> +	int nHdrLen = 0;
> +

Which checkpatch complaints does this fix?  That should be mentioned
in the changelog probably.

Anyway, it's the the wrong thing to do.  The variables should be
declared in the case block where they are used.  It means that we
don't have to read as much code to understand what is happenning.

Also, don't initialize variables unless it's needed.  You're turning
off the gcc uninitialized variable warning for no reason.
Occasionally I see bugs that GCC would have caught if only people
hadn't initialized all their pointers to NULL without thinking about
it.

When gcc does give uninitialized warning messages then sure
sometimes it's easy to just initialize it to NULL.  The kernel also
provides an uninitialized_var() macro to silence the warning.  But
the other thing you can do is to just handle the fall through
default case.  Maybe in a year or two we'll add some new PCI IDs
or whatever and handling the unexpected conditions will mean the
kernel doesn't crash.

regards,
dan carpenter

Attachment: signature.asc
Description: Digital signature

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux