All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Geyslan G. Bem" <geyslan@gmail.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: Peter Senna Tschudin <peter.senna@gmail.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/9v2] usb: host: ehci.h: fix single statement macros
Date: Thu, 10 Dec 2015 11:56:35 -0300	[thread overview]
Message-ID: <CAGG-pUSrbuT0Kh7k16ZZR5_3ibekHCgSAGLhVnjkvOrQHY5BCg@mail.gmail.com> (raw)
In-Reply-To: <56698FB3.9030705@cogentembedded.com>

2015-12-10 11:44 GMT-03:00 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>:
> On 12/10/2015 04:05 PM, Geyslan G. Bem wrote:
>
>>>>> Don't use the 'do {} while (0)' wrapper in a single statement macro.
>>>>>
>>>>> Caught by checkpatch: "WARNING: Single statement macros should not
>>>>> use a do {} while (0) loop"
>>>>>
>>>>> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
>>>>> ---
>>>>>    drivers/usb/host/ehci.h | 4 ++--
>>>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
>>>>> index cfeebd8..945000a 100644
>>>>> --- a/drivers/usb/host/ehci.h
>>>>> +++ b/drivers/usb/host/ehci.h
>>>>> @@ -244,9 +244,9 @@ struct ehci_hcd {                   /* one per
>>>>> controller */
>>>>>          /* irq statistics */
>>>>>    #ifdef EHCI_STATS
>>>>>          struct ehci_stats       stats;
>>>>> -#      define COUNT(x) do { (x)++; } while (0)
>>>>> +#      define COUNT(x) ((x)++)
>>>>>    #else
>>>>> -#      define COUNT(x) do {} while (0)
>>>>> +#      define COUNT(x) ((void) 0)
>>>>
>>>>
>>>>
>>>>     Why not just empty #define?
>>>
>>>
>>> Indeed. I'll change it.
>>> Tks Sergei.
>>
>>
>> Since COUNT is not used to return the empty #define is ok. Another way
>> is to use #define COUNT(x) (0) to get a 0 when necessary to read
>> returns.
>
>
>    Just 0, no parens please.
Ok, no parens, since there's no evaluation.

Then my change is:

-#      define COUNT(x) do { (x)++; } while (0)
+#      define COUNT(x) (++(x))
 #else
-#      define COUNT(x) do {} while (0)
+#      define COUNT(x) 0

Pre-increment allowing to return the updated x.

>
> MBR, Sergei
>



-- 
Regards,

Geyslan G. Bem
hackingbits.com

  reply	other threads:[~2015-12-10 14:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 22:32 [PATCH 1/9v2] usb: host: ehci.h: remove space before comma Geyslan G. Bem
2015-12-09 22:32 ` [PATCH 2/9v2] usb: host: ehci.h: remove space before function open parenthesis Geyslan G. Bem
2015-12-10  9:24   ` Peter Senna Tschudin
2015-12-09 22:32 ` [PATCH 3/9v2] usb: host: ehci.h: remove space before open square bracket Geyslan G. Bem
2015-12-10  9:27   ` Peter Senna Tschudin
2015-12-09 22:32 ` [PATCH 4/9v2] usb: host: ehci.h: fix single statement macros Geyslan G. Bem
2015-12-10  9:58   ` Peter Senna Tschudin
2015-12-10 11:54   ` Sergei Shtylyov
2015-12-10 12:20     ` Geyslan G. Bem
2015-12-10 13:05       ` Geyslan G. Bem
2015-12-10 14:44         ` Sergei Shtylyov
2015-12-10 14:56           ` Geyslan G. Bem [this message]
2015-12-10 17:26             ` Sergei Shtylyov
2015-12-10 17:40               ` Geyslan G. Bem
2015-12-10 17:47                 ` Sergei Shtylyov
2015-12-10 18:04                   ` Geyslan G. Bem
2015-12-09 22:32 ` [PATCH 5/9v2] usb: host: ehci.h: remove direct use of __attribute__ keyword Geyslan G. Bem
2015-12-10 10:01   ` Peter Senna Tschudin
2015-12-10 10:25     ` Geyslan G. Bem
2015-12-09 22:32 ` [PATCH 6/9v2] usb: host: ehci.h: use space after comma Geyslan G. Bem
2015-12-10 10:18   ` Peter Senna Tschudin
2015-12-10 15:57     ` Alan Stern
2015-12-10 16:02       ` Geyslan G. Bem
2015-12-09 22:32 ` [PATCH 7/9v2] usb: host: ehci.h: remove macros trailing semicolon Geyslan G. Bem
2015-12-10 10:20   ` Peter Senna Tschudin
2015-12-09 22:32 ` [PATCH 8/9v2] usb: host: ehci.h: move pointer operator to name side Geyslan G. Bem
2015-12-10 10:21   ` Peter Senna Tschudin
2015-12-10  9:15 ` [PATCH 1/9v2] usb: host: ehci.h: remove space before comma Peter Senna Tschudin

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=CAGG-pUSrbuT0Kh7k16ZZR5_3ibekHCgSAGLhVnjkvOrQHY5BCg@mail.gmail.com \
    --to=geyslan@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.senna@gmail.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=stern@rowland.harvard.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.