lkml.org 
[lkml]   [2015]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] staging: dgnc: Patch includes the checkpatch fixes
On Fri, Dec 11, 2015 at 05:10:43AM -0500, Sanidhya Solanki wrote:
> On Fri, 11 Dec 2015 16:02:33 +0300
> Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> > > Signed-off-by: Sanidhya Solanki <jpage.lkml@gmail.com>
> > > @@ -110,7 +98,16 @@ static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr,
> > > int count = 0;
> > > int i = 0;
> > >
> > > - 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);
> >
> > Google about why do while(0) loops are used in macros and then redo
> > this. Mostly the patch isn't bad, but I suspect I'm going to complain
> > about how you split up some of the long lines.
>
> Let me just be completely sure that you and I are on the same page
> here. The macro was used to replace the do-while loop, I replaced all
> instances of the macro with the the actual loop. Both pieces were
> originally part of the code, just using macros in place of do-while
> statements. Do you still want me to change it? Maybe the original
> author did it for a specific reason.
>

https://www.quora.com/What-is-the-purpose-of-using-do-while-0-in-macros

Do while(0) is used to make a macro look like a function. Since we have
deleted the macro we don't need the do while.

regards,
dan carpenter



\
 
 \ /
  Last update: 2015-12-11 15:41    [W:0.155 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site