[PATCH] staging: dgnc: Warn on macro with flow control statements
Greg KH
gregkh at linuxfoundation.org
Fri Feb 27 03:53:26 UTC 2015
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 at acm.org>
> ---
> 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.
More information about the devel
mailing list