mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 3/5] staging: rtl8192e: fix coding style errors (macros in parentheses)
Date: Mon, 16 Mar 2015 23:58:45 +0100	[thread overview]
Message-ID: <55076025.3060109@gmail.com> (raw)
In-Reply-To: <1426481460.2678.35.camel@perches.com>

On 16.03.2015 05:51, Joe Perches wrote:
> On Sun, 2015-03-15 at 21:39 +0100, Mateusz Kulikowski wrote:
>> Fix checkpatch.pl errors 'Macros with complex values should be enclosed in parentheses'.
> []
>> diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h
> []
>> @@ -78,7 +78,7 @@ enum chnl_op {
>>  };
>>  
>>  #define CHHLOP_IN_PROGRESS(_pHTInfo)	\
>> -		((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? true : false
>> +		(((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? true : false)
> 
> This would perhaps be better without the ternary as
> the compiler might not optimize the ternary away
> 
> #define CHHLOP_IN_PROGRESS(_pHTInfo)				\
> 	((_pHTInfo)->ChnOp > CHNLOP_NONE)
> 
> This would also probably be better as a static inline
> not a macro, but as this is never used it's actually
> better just to remove it.

Thanks for the hints, done in v5 (other macros were also harmed)

> 
>> @@ -385,8 +385,8 @@ extern u8 MCS_FILTER_1SS[16];
>>  #define	LEGACY_WIRELESS_MODE	IEEE_MODE_MASK
>>  
>>  #define CURRENT_RATE(WirelessMode, LegacyRate, HTRate)	\
>> -			((WirelessMode & (LEGACY_WIRELESS_MODE)) != 0) ? \
>> -			(LegacyRate) : (PICK_RATE(LegacyRate, HTRate))
>> +			(((WirelessMode & (LEGACY_WIRELESS_MODE)) != 0) ? \
>> +			(LegacyRate) : (PICK_RATE(LegacyRate, HTRate)))
> 
> This would be better with the various macro arguments
> parenthesized (especially WirelessMode)
> 
> #define CURRENT_RATE(WirelessMode, LegacyRate, HTRate)		\
> 	(((WirelessMode) & LEGACY_WIRELESS_MODE)  ? 		\
> 	(LegacyRate) : PICK_RATE((LegacyRate), HTRate))
> 
> As this is used exactly once, it's probably better
> expanded in that one place and the macro removed.
> 
> That's true for PICK_RATE as well.

Will replace with static function (in .c file) - code that uses this macro is nested enough

Regards
Mateusz


  reply	other threads:[~2015-03-16 22:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-15 20:39 [PATCH v4 0/5] staging: rtl8192e: fix coding style issues Mateusz Kulikowski
2015-03-15 20:39 ` [PATCH v4 1/5] staging: rtl8192e: fix coding style issues (merge broken strings) Mateusz Kulikowski
2015-03-16 15:02   ` Greg KH
2015-03-15 20:39 ` [PATCH v4 2/5] staging: rtl8192e: fix coding style issues (spaces before semicolon) Mateusz Kulikowski
2015-03-15 20:39 ` [PATCH v4 3/5] staging: rtl8192e: fix coding style errors (macros in parentheses) Mateusz Kulikowski
2015-03-16  4:51   ` Joe Perches
2015-03-16 22:58     ` Mateusz Kulikowski [this message]
2015-03-15 20:39 ` [PATCH v4 4/5] staging: rtl8192e: rtllib_wx: remove duplicate messages Mateusz Kulikowski
2015-03-15 20:39 ` [PATCH v4 5/5] staging: rtl8192e: fix coding style warnings (printk -> netdev_*) Mateusz Kulikowski

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=55076025.3060109@gmail.com \
    --to=mateusz.kulikowski@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.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

Powered by JetHome