staging: rtl8188eu: remove unnecessary asignment
PATCH 1/2 staging: rtl8188eu: remove unnecessary asignment
Remove unnecessary asignment in SwLedBlink1(). The code path with the asignment 'pLed->BlinkTimes = 0' is only executed when 'pLed->BlinkTimes' is already zero and the value is not changed between the test 'if (pLed->BlinkTimes == 0)' and the asignment.
--- drivers/staging/rtl8188eu/core/rtw_led.c | 1 - 1 file changed, 1 deletion(-)
drivers/staging/rtl8188eu/core/rtw_led.c +0 -1
@@ -188,7 +188,6 @@ static void SwLedBlink1(struct LED_871x *pLed) msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));RT_TRACE (_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n" , pLed->CurrLedState)); } - pLed->BlinkTimes =0 ; pLed->bLedBlinkInProgress = false; }else {if (pLed->bLedOn)
Signature · 1 line
2.26.0
PATCH 2/2 staging: rtl8188eu: remove unnecessary variable
The variable 'bStopBlinking' is used in if tests immediately after its value is set. Use the conditions for setting 'bStopBlinking' diretly in the subsequent if tests and remove the variable. Slightly reduces object file size by 16 bytes (gcc 9.2.1 x86_64).
--- drivers/staging/rtl8188eu/core/rtw_led.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/staging/rtl8188eu/core/rtw_led.c +3 -13
@@ -90,7 +90,6 @@ static void SwLedBlink1(struct LED_871x *pLed) {struct adapter *padapter = pLed->padapter;struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -u8 bStopBlinking = false;/* Change LED according to BlinkingLedState specified. */ if (pLed->BlinkingLedState ==RTW_LED_ON ) {
@@ -128,9 +127,7 @@ static void SwLedBlink1(struct LED_871x *pLed)break ;case LED_BLINK_SCAN : pLed->BlinkTimes--; -if (pLed->BlinkTimes ==0 ) - bStopBlinking = true; -if (bStopBlinking) { +if (pLed->BlinkTimes ==0 ) {if (check_fwstate (pmlmepriv, _FW_LINKED)) { pLed->bLedLinkBlinkInProgress = true; pLed->CurrLedState =LED_BLINK_NORMAL ;
@@ -164,9 +161,7 @@ static void SwLedBlink1(struct LED_871x *pLed)break ;case LED_BLINK_TXRX : pLed->BlinkTimes--; -if (pLed->BlinkTimes ==0 ) - bStopBlinking = true; -if (bStopBlinking) { +if (pLed->BlinkTimes ==0 ) {if (check_fwstate (pmlmepriv, _FW_LINKED)) { pLed->bLedLinkBlinkInProgress = true; pLed->CurrLedState =LED_BLINK_NORMAL ;
@@ -207,12 +202,7 @@ static void SwLedBlink1(struct LED_871x *pLed) msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));break ;case LED_BLINK_WPS_STOP :/* WPS success */ -if (pLed->BlinkingLedState ==RTW_LED_ON ) - bStopBlinking = false; -else - bStopBlinking = true; - -if (bStopBlinking) { +if (pLed->BlinkingLedState !=RTW_LED_ON ) { pLed->bLedLinkBlinkInProgress = true; pLed->CurrLedState =LED_BLINK_NORMAL ;if (pLed->bLedOn)
Signature · 1 line
2.26.0
Dan Carpenter
Reviewed-byQuoted 9 lines · Dan Carpenter
Quoted 5 lines · Michael Straube
Remove unnecessary asignment in
SwLedBlink1(). The code path with the asignment 'pLed->BlinkTimes= 0' is only executed when 'pLed->BlinkTimes' is already zero and the value is not changed between the test 'if (pLed->BlinkTimes== 0)' and the asignment.Better to get rid of the bStopBlinking variable and this becomes more obvious.
Oh, never mind. You did that in patch 2. This is fine then.
regards,
dan carpenter
Quoted 5 lines · Michael Straube
Remove unnecessary asignment in
SwLedBlink1(). The code path with the asignment 'pLed->BlinkTimes= 0' is only executed when 'pLed->BlinkTimes' is already zero and the value is not changed between the test 'if (pLed->BlinkTimes== 0)' and the asignment.
Better to get rid of the bStopBlinking variable and this becomes more obvious.
regards,
dan carpenter