From: Michael Straube <michael.straube@posteo.de>
To: Joe Perches <joe@perches.com>, Dan Carpenter <dan.carpenter@oracle.com>
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8723bs: do not use assignment in if condition
Date: Fri, 22 Jun 2018 21:11:47 +0200 [thread overview]
Message-ID: <2c2a0f79-7970-8c55-6119-189114b279e3@posteo.de> (raw)
In-Reply-To: <36a7227189b8c7602dd9ffd21a5369b7029e61f1.camel@perches.com>
On 06/22/18 19:28, Joe Perches wrote:
> On Fri, 2018-06-22 at 14:48 +0200, Michael Straube wrote:
>> On 06/22/18 12:57, Dan Carpenter wrote:
>>> On Fri, Jun 22, 2018 at 03:54:22AM -0700, Joe Perches wrote:
>>>> On Fri, 2018-06-22 at 13:40 +0300, Dan Carpenter wrote:
>>>>> On Thu, Jun 21, 2018 at 08:22:30PM +0200, Michael Straube wrote:
>>>>>> Fix checkpatch error 'do not use assignment in if condition'.
>>>> []
>>>>>> diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
>>>>>> index e55895632921..87a4ced41028 100644
>>>>>> --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
>>>>>> +++ b/
>>>>>> @@ -1181,9 +1181,8 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr)
>>>>>> (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) ||
>>>>>> ((mac[0] == 0x00) && (mac[1] == 0x00) && (mac[2] == 0x00) &&
>>>>>> (mac[3] == 0x00) && (mac[4] == 0x00) && (mac[5] == 0x00))) {
>>>>
>>>> Should also use is_broadcast_ether_addr and is_zero_ether_addr
>>>>
>>>>>> - if (np &&
>>>>>> - (addr = of_get_property(np, "local-mac-address", &len)) &&
>>>>>> - len == ETH_ALEN) {
>>>>>> + addr = of_get_property(np, "local-mac-address", &len);
>>>>>> + if (np && addr && len == ETH_ALEN) {
>>>>>
>>>>> You can remove the "np" check.
>>>>>
>>>>> if (addr && len == ETH_ALEN) {
>>>>
>>>> It looks more like the rewrite is incorrect
>>>> as np is tested before of_get_property
>>>>
>>>
>>> That's what I was worried about too, but if "np" is NULL then
>>> of_get_property() just returns NULL so it's fine.
>>
>> So it should be this?
>>
>> if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) &&
>> (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) ||
>> ((mac[0] == 0x00) && (mac[1] == 0x00) && (mac[2] == 0x00) &&
>> (mac[3] == 0x00) && (mac[4] == 0x00) && (mac[5] == 0x00)) &&
>> (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac))) {
>
> No as the mac[] tests are the same as is_<foo>_ether_addr
Ok, I understand now.
> and there's nothing really objectionable about embedding
> the assignment in the if here.
>
> Output from checkpatch is not gospel and can be ignored
> whenever appropriate.
Ok, good to know.
> memcpy(mac_addr, ""\x00\xe0\x4c\x87\x00\x00", ETH_ALEN);
>
> Although the last memcpy of a fixed mac address could
> probably use eth_random_addr to reduce the likelihood
> of mac address collision so maybe
>
> eth_random_addr(mac_addr);
Using a random address would be preffered?
Thanks for your help and patience.
Michael
next prev parent reply other threads:[~2018-06-22 19:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-21 18:22 [PATCH] staging: rtl8723bs: do not use assignment in if condition Michael Straube
2018-06-22 10:40 ` Dan Carpenter
2018-06-22 10:54 ` Joe Perches
2018-06-22 10:57 ` Dan Carpenter
2018-06-22 12:48 ` Michael Straube
2018-06-22 17:28 ` Joe Perches
2018-06-22 19:11 ` Michael Straube [this message]
2018-06-23 1:59 ` Joe Perches
2018-06-25 9:49 ` Andy Shevchenko
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=2c2a0f79-7970-8c55-6119-189114b279e3@posteo.de \
--to=michael.straube@posteo.de \
--cc=dan.carpenter@oracle.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;
as well as URLs for NNTP newsgroup(s).