[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.20.1610161525490.2207@hadrien>
Date: Sun, 16 Oct 2016 15:30:57 +0200 (CEST)
From: Julia Lawall <julia.lawall@...6.fr>
To: Siddhi Dave <d.sandy5990@...il.com>
cc: lidza.louina@...il.com, markh@...pro.net,
gregkh@...uxfoundation.org, driverdev-devel@...uxdriverproject.org,
devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
outreachy-kernel@...glegroups.com
Subject: Re: [Outreachy kernel] [PATCH] Staging: dgnc: Clean up Macros
On Sun, 16 Oct 2016, Siddhi Dave wrote:
> Fix checkpatch warning: Macros with flow control statements should be avoided
>
> Because Macros with flow control statements (goto and return) are
> not very nice to read as any flow movement is unexpected.
>
> Signed-off-by: Siddhi Dave <d.sandy5990@...il.com>
> ---
> drivers/staging/dgnc/dgnc_sysfs.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c
> index 290bf6e..0767740 100644
> --- a/drivers/staging/dgnc/dgnc_sysfs.c
> +++ b/drivers/staging/dgnc/dgnc_sysfs.c
> @@ -90,16 +90,16 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver)
> driver_remove_file(driverfs, &driver_attr_pollrate);
> }
>
> -#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; \
> +#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)
This does not look correct. You are still sort of defining a macro,
except that you have dropped all of the \s. A macro has to be defined on
a single line, or a line continued with \, so this would cause major
syntax errors. I think that someone else worked on similar code and found
that some of the tests were also not needed in the context in which this
code is used.
julia
>
> static ssize_t vpd_show(struct device *p, struct device_attribute *attr,
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@...glegroups.com.
> To post to this group, send email to outreachy-kernel@...glegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20161016124231.GA18162%40siddhi-home-laptop.
> For more options, visit https://groups.google.com/d/optout.
>
Powered by blists - more mailing lists