Re: [PATCH] staging: dgnc: Warn on macro with flow control statements

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

 



On Fri, Feb 27, 2015 at 03:40:11AM +0100, Salah Triki wrote:
> This fixes the following checkpatch.pl warnings:
> WARNING: Macros with flow control statements should be avoided.
> 
> Signed-off-by: Salah Triki <salah.triki@xxxxxxx>
> ---
>  drivers/staging/dgnc/dgnc_sysfs.c | 64 ++++++++++++++++++++++++---------------
>  1 file changed, 39 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c
> index 2fd34ca..8e9eca4 100644
> --- a/drivers/staging/dgnc/dgnc_sysfs.c
> +++ b/drivers/staging/dgnc/dgnc_sysfs.c
> @@ -106,18 +106,19 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver)
>  }
> 
> 
> -#define DGNC_VERIFY_BOARD(p, bd)				\
> -	do {							\
> -		if (!p)						\
> -			return 0;				\
> -								\
> -		bd = dev_get_drvdata(p);			\
> -		if (!bd || bd->magic != DGNC_BOARD_MAGIC)	\
> -			return 0;				\
> -		if (bd->state != BOARD_READY)			\
> -			return 0;				\
> -	} while (0)
> +static int dgnc_verify_board(struct device *p, struct dgnc_board *bd)
> +{
> +	if (!p)
> +		return -1;

Don't make up random error values.

How can p ever be NULL?

> 
> +	bd = dev_get_drvdata(p);
> +	if (!bd || bd->magic != DGNC_BOARD_MAGIC)

How can these ever be true?

> +		return -1;
> +
> +	if (bd->state != BOARD_READY)

How can this be true?

I recommend just removing the whole check.

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-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