diff mbox

rtlwifi: rtl8192cu: Remove variable self-assignment in rf.c

Message ID 20180207202634.98937-1-mka@chromium.org (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show

Commit Message

Matthias Kaehlcke Feb. 7, 2018, 8:26 p.m. UTC
In _rtl92c_get_txpower_writeval_by_regulatory() the variable writeVal
is assigned to itself in an if ... else statement, apparently only to
document that the branch condition is handled and that a previously read
value should be returned unmodified. The self-assignment causes clang to
raise the following warning:

drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c:304:13:
  error: explicitly assigning value of variable of type 'u32'
    (aka 'unsigned int') to itself [-Werror,-Wself-assign]
  writeVal = writeVal;

Replace the self-assignment with a semicolon, which still serves to
document the 'handling' of the branch condition.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Larry Finger Feb. 7, 2018, 8:35 p.m. UTC | #1
On 02/07/2018 02:26 PM, Matthias Kaehlcke wrote:
> In _rtl92c_get_txpower_writeval_by_regulatory() the variable writeVal
> is assigned to itself in an if ... else statement, apparently only to
> document that the branch condition is handled and that a previously read
> value should be returned unmodified. The self-assignment causes clang to
> raise the following warning:
> 
> drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c:304:13:
>    error: explicitly assigning value of variable of type 'u32'
>      (aka 'unsigned int') to itself [-Werror,-Wself-assign]
>    writeVal = writeVal;
> 
> Replace the self-assignment with a semicolon, which still serves to
> document the 'handling' of the branch condition.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>   drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
> index 9cff6bc4049c..4db92496c122 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
> @@ -301,7 +301,7 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
>   			writeVal = writeVal - 0x06060606;
>   		else if (rtlpriv->dm.dynamic_txhighpower_lvl ==
>   			 TXHIGHPWRLEVEL_BT2)
> -			writeVal = writeVal;
> +			;
>   		*(p_outwriteval + rf) = writeVal;
>   	}
>   }
> 

As the branch condition does nothing, why not remove it and save the compiler's 
optimizer a bit of work? The code looks strange, but it matches the rest of 
Realtek's USB drivers.

Larry
Matthias Kaehlcke Feb. 7, 2018, 8:51 p.m. UTC | #2
El Wed, Feb 07, 2018 at 02:35:59PM -0600 Larry Finger ha dit:

> On 02/07/2018 02:26 PM, Matthias Kaehlcke wrote:
> > In _rtl92c_get_txpower_writeval_by_regulatory() the variable writeVal
> > is assigned to itself in an if ... else statement, apparently only to
> > document that the branch condition is handled and that a previously read
> > value should be returned unmodified. The self-assignment causes clang to
> > raise the following warning:
> > 
> > drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c:304:13:
> >    error: explicitly assigning value of variable of type 'u32'
> >      (aka 'unsigned int') to itself [-Werror,-Wself-assign]
> >    writeVal = writeVal;
> > 
> > Replace the self-assignment with a semicolon, which still serves to
> > document the 'handling' of the branch condition.
> > 
> > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> > ---
> >   drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
> > index 9cff6bc4049c..4db92496c122 100644
> > --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
> > +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
> > @@ -301,7 +301,7 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
> >   			writeVal = writeVal - 0x06060606;
> >   		else if (rtlpriv->dm.dynamic_txhighpower_lvl ==
> >   			 TXHIGHPWRLEVEL_BT2)
> > -			writeVal = writeVal;
> > +			;
> >   		*(p_outwriteval + rf) = writeVal;
> >   	}
> >   }
> > 
> 
> As the branch condition does nothing, why not remove it and save the
> compiler's optimizer a bit of work? The code looks strange, but it matches
> the rest of Realtek's USB drivers.

Sure, I am happy to change it to whatever the authors/maintainers prefer.

I'll wait a bit before respinning for if others feel strongly about
keeping the branch.
Ping-Ke Shih Feb. 8, 2018, 1:06 a.m. UTC | #3
On Wed, 2018-02-07 at 12:51 -0800, Matthias Kaehlcke wrote:
> El Wed, Feb 07, 2018 at 02:35:59PM -0600 Larry Finger ha dit:

> 

> > On 02/07/2018 02:26 PM, Matthias Kaehlcke wrote:

> > > In _rtl92c_get_txpower_writeval_by_regulatory() the variable writeVal

> > > is assigned to itself in an if ... else statement, apparently only to

> > > document that the branch condition is handled and that a previously read

> > > value should be returned unmodified. The self-assignment causes clang to

> > > raise the following warning:

> > > 

> > > drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c:304:13:

> > >    error: explicitly assigning value of variable of type 'u32'

> > >      (aka 'unsigned int') to itself [-Werror,-Wself-assign]

> > >    writeVal = writeVal;

> > > 

> > > Replace the self-assignment with a semicolon, which still serves to

> > > document the 'handling' of the branch condition.

> > > 

> > > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>

> > > ---

> > >   drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c | 2 +-

> > >   1 file changed, 1 insertion(+), 1 deletion(-)

> > > 

> > > diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c

> b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c

> > > index 9cff6bc4049c..4db92496c122 100644

> > > --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c

> > > +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c

> > > @@ -301,7 +301,7 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw

> *hw,

> > >   			writeVal = writeVal - 0x06060606;

> > >   		else if (rtlpriv->dm.dynamic_txhighpower_lvl ==

> > >   			 TXHIGHPWRLEVEL_BT2)

> > > -			writeVal = writeVal;

> > > +			;

> > >   		*(p_outwriteval + rf) = writeVal;

> > >   	}

> > >   }

> > > 

> > 

> > As the branch condition does nothing, why not remove it and save the

> > compiler's optimizer a bit of work? The code looks strange, but it matches

> > the rest of Realtek's USB drivers.


Agree Larry's comment.

> 

> Sure, I am happy to change it to whatever the authors/maintainers prefer.

> 

> I'll wait a bit before respinning for if others feel strongly about

> keeping the branch.

> 

> ------Please consider the environment before printing this e-mail.
diff mbox

Patch

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
index 9cff6bc4049c..4db92496c122 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
@@ -301,7 +301,7 @@  static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
 			writeVal = writeVal - 0x06060606;
 		else if (rtlpriv->dm.dynamic_txhighpower_lvl ==
 			 TXHIGHPWRLEVEL_BT2)
-			writeVal = writeVal;
+			;
 		*(p_outwriteval + rf) = writeVal;
 	}
 }