linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Sanidhya Solanki <jpage.lkml@gmail.com>
Cc: devel@driverdev.osuosl.org, lidza.louina@gmail.com,
	driverdev-devel@linuxdriverproject.org,
	linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org
Subject: Re: [PATCH] staging: dgnc: Patch includes the checkpatch fixes
Date: Fri, 11 Dec 2015 17:18:45 +0300	[thread overview]
Message-ID: <20151211141845.GK5284@mwanda> (raw)
In-Reply-To: <20151211051043.4f7d24df@gmail.com>

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


  reply	other threads:[~2015-12-11 14:18 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-11  8:21 [PATCH] staging: dgnc: Patch includes the checkpatch fixes Sanidhya Solanki
2015-12-11 13:02 ` Dan Carpenter
2015-12-11 10:10   ` Sanidhya Solanki
2015-12-11 14:18     ` Dan Carpenter [this message]
2015-12-12  2:15   ` [PATCH] staging: dgnc: Update the TODO file Sanidhya Solanki
2015-12-12  2:24   ` [PATCH] staging: dgnc: Patch includes the checkpatch fixes Sanidhya Solanki
2015-12-12  8:57     ` Dan Carpenter
2015-12-12  7:58       ` [PATCH] [PATCH 1/3] " Sanidhya Solanki
2015-12-14 19:14         ` Greg KH
2015-12-15  0:01           ` Sanidhya Solanki
2015-12-15  0:02           ` Sanidhya Solanki
2015-12-15  0:03           ` Sanidhya Solanki
2015-12-15  4:34             ` Greg KH
2015-12-15  0:45               ` Sanidhya Solanki
2015-12-15  5:21                 ` Greg KH
2015-12-15  1:22                   ` [PATCH FIXED " Sanidhya Solanki
2015-12-15  5:46                     ` Greg KH
2015-12-15  1:56                       ` [PATCH FIXED 1/3] staging: dgnc: Patch includes spacing fixes Sanidhya Solanki
2015-12-15  2:00                         ` [PATCH 2/3] staging: dgnc: Patch includes CamelCase & Macro fixes Sanidhya Solanki
2015-12-15  1:58                       ` [PATCH 1/3] staging: dgnc: Patch includes the checkpatch fixes Sanidhya Solanki
2015-12-15  6:37                         ` Amitoj Kaur Chawla
2015-12-15  6:38                         ` Greg KH
2015-12-15  2:01                       ` [PATCH 3/3] staging: dgnc: Patch updates the TODO file Sanidhya Solanki
2015-12-15  1:24                   ` [PATCH FIXED 2/3] staging: dgnc: Patch for CamelCase fixes Sanidhya Solanki
2015-12-15  1:25                   ` [PATCH FIXED 3/3] staging: dgnc: Patch updates the TODO file Sanidhya Solanki
2015-12-12  8:00       ` [PATCH 2/3] staging: dgnc: Patch includes the checkpatch fixes Sanidhya Solanki
2015-12-12  8:03       ` [PATCH 3/3] " Sanidhya Solanki
2015-12-12  8:09       ` [PATCH] " Sanidhya Solanki
2015-12-12 10:08       ` Sudip Mukherjee
2015-12-12  6:12         ` Sanidhya Solanki
2015-12-12 10:26           ` Sudip Mukherjee
     [not found] ` <20151211210443.48f43b77@gmail.com>
2015-12-12  2:11   ` [PATCH: FIXED} " Sanidhya Solanki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151211141845.GK5284@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jpage.lkml@gmail.com \
    --cc=lidza.louina@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).