Skip to contentSkip to conversation

brcmsmac: Remove always false 'channel < 0' statement

PATCH In review Austin Kim 3 participants 6 messages Nov 27, 2019 – Dec 18, 2019 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Austin Kim

author
#0 lore raw

PATCH 1/1 brcmsmac: Remove always false 'channel < 0' statement

As 'channel' is declared as u16, the following statement is always false.
channel < 0

So we can remove unnecessary 'always false' statement.

---
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +1 -1
index 3f09d89..7f2c15c 100644
@@ -5408,7 +5408,7 @@ int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel)
 {
 	u16 chspec = ch20mhz_chspec(channel);
 
-	if (channel < 0 || channel > MAXCHANNEL)
+	if (channel > MAXCHANNEL)
 		return -EINVAL;
 
 	if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec))
Signature · 1 line
2.6.2
#1 lore raw
Quoted 4 lines · Austin Kim

As 'channel' is declared as u16, the following statement is always false.
channel < 0

So we can remove unnecessary 'always false' statement.

It's an expression, not a statement.

Quoted 10 lines
---
  drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +0 -0
index 3f09d89..7f2c15c 100644

drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel) · line 5414

Quoted 8 lines
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +1 -1
@@ -5408,7 +5408,7 @@ int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel)
  {
  	u16 chspec = ch20mhz_chspec(channel);
 
-	if (channel < 0 || channel > MAXCHANNEL)
+	if (channel > MAXCHANNEL)
  		return -EINVAL;
 
  	if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec))

MBR, Sergei

author
#2 lore raw

2019년 11월 27일 (수) 오후 7:48, Sergei Shtylyov
<[email protected]>님이 작성:

Quoted 10 lines · Austin Kim
Quoted 5 lines

As 'channel' is declared as u16, the following statement is always false.
channel < 0

So we can remove unnecessary 'always false' statement.

It's an expression, not a statement.

According to below link, it is okay to use 'statement' in above case.
https://en.wikipedia.org/wiki/Statement_(computer_science)

Why don't you show your opition about patch rather than commit message?

Thanks,
Austin Kim

Quoted 21 lines
Quoted 10 lines
---
  drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +0 -0
index 3f09d89..7f2c15c 100644

drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel) · line 5414

Quoted 8 lines
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +1 -1
@@ -5408,7 +5408,7 @@ int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel)
  {
      u16 chspec = ch20mhz_chspec(channel);
 
-     if (channel < 0 || channel > MAXCHANNEL)
+     if (channel > MAXCHANNEL)
              return -EINVAL;
 
      if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec))

MBR, Sergei

#3 lore raw
Quoted 8 lines · Austin Kim

2019년 11월 27일 (수) 오후 7:48, Sergei Shtylyov
<[email protected]>님이 작성:

Quoted 6 lines · Austin Kim
Quoted 4 lines

As 'channel' is declared as u16, the following statement is always false.
channel < 0

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

So we can remove unnecessary 'always false' statement.

It's an expression, not a statement.

According to below link, it is okay to use 'statement' in above case.
https://en.wikipedia.org/wiki/Statement_(computer_science)

I don't have time to start arguing about this, and I'm no C language lawyer either, but all I say is that I agree with Sergei here.

Quoted 1 line

Why don't you show your opition about patch rather than commit message?

But this comment is not ok. Patch review (including commit logs) is the core principle of upstream development so you need to have an open mind for all comments, even the ones you don't like.

Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

A message that is not in the archive (sent off-list or not yet received): 0101016ead12c253-18d4624e-98eb-4252-ba3a-fabf74d831f2-000000@us-west-2.amazonses.com

author
#5 lore raw

2019년 11월 27일 (수) 오후 10:35, Kalle Valo <[email protected]>님이 작성:

Quoted 13 lines
Quoted 10 lines · Austin Kim

2019년 11월 27일 (수) 오후 7:48, Sergei Shtylyov
<[email protected]>님이 작성:

Quoted 8 lines · Austin Kim
Quoted 5 lines

As 'channel' is declared as u16, the following statement is always false.
channel < 0

So we can remove unnecessary 'always false' statement.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

It's an expression, not a statement.

According to below link, it is okay to use 'statement' in above case.
https://en.wikipedia.org/wiki/Statement_(computer_science)

I don't have time to start arguing about this, and I'm no C language lawyer either, but all I say is that I agree with Sergei here.

Thanks for your opinion.
I will use 'expression' rather than 'statement' when I upstream similar patch later.

Quoted 6 lines
Quoted 2 lines

Why don't you show your opition about patch rather than commit message?

But this comment is not ok. Patch review (including commit logs) is the core principle of upstream development so you need to have an open mind for all comments, even the ones you don't like.

Oh! I Agreed.
If I were you, I would leave similar comment.

Thanks,
Austin Kim

Quoted 3 lines

--
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

#6 lore raw
In reply to Austin Kim
Quoted 6 lines · Austin Kim

As 'channel' is declared as u16, the following expression is always false.
channel < 0

So we can remove unnecessary 'always false' statement.

Patch applied to wireless-drivers-next.git, thanks.

37bc6c72f5b7 brcmsmac: Remove always false 'channel < 0' statement

Signature · 3 lines
https://patchwork.kernel.org/patch/11263483/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches