Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1643660 > unrolled thread

[net-realtek-btcoexist] question about identical code for different branches

Started by"Gustavo A. R. Silva" <garsilva@embeddedor.com>
First post2017-05-18 00:00 +0200
Last post2017-05-18 03:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [net-realtek-btcoexist] question about identical code for different  branches "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-05-18 00:00 +0200
    Re: [net-realtek-btcoexist] question about identical code for  different branches Larry Finger <Larry.Finger@lwfinger.net> - 2017-05-18 03:40 +0200

#1643660 — [net-realtek-btcoexist] question about identical code for different branches

From"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Date2017-05-18 00:00 +0200
Subject[net-realtek-btcoexist] question about identical code for different branches
Message-ID<tIf97-cH-5@gated-at.bofh.it>
Hello everybody,

While looking into Coverity ID 1362263 I ran into the following piece  
of code at  
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c:1000:

1000void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
1001{
1002        if (BT_COEX_ANT_TYPE_PG == type) {
1003                gl_bt_coexist.board_info.pg_ant_num = ant_num;
1004                gl_bt_coexist.board_info.btdm_ant_num = ant_num;
1005                /* The antenna position:
1006                 * Main (default) or Aux for pgAntNum=2 && btdmAntNum =1.
1007                 * The antenna position should be determined by
1008                 * auto-detect mechanism.
1009                 * The following is assumed to main,
1010                 * and those must be modified
1011                 * if y auto-detect mechanism is ready
1012                 */
1013                if ((gl_bt_coexist.board_info.pg_ant_num == 2) &&
1014                    (gl_bt_coexist.board_info.btdm_ant_num == 1))
1015                        gl_bt_coexist.board_info.btdm_ant_pos =
1016                                                        
BTC_ANTENNA_AT_MAIN_PORT;
1017                else
1018                        gl_bt_coexist.board_info.btdm_ant_pos =
1019                                                        
BTC_ANTENNA_AT_MAIN_PORT;
1020        } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
1021                gl_bt_coexist.board_info.btdm_ant_num = ant_num;
1022                gl_bt_coexist.board_info.btdm_ant_pos =
1023                                                        
BTC_ANTENNA_AT_MAIN_PORT;
1024        } else if (type == BT_COEX_ANT_TYPE_DETECTED) {
1025                gl_bt_coexist.board_info.btdm_ant_num = ant_num;
1026                if (rtlpriv->cfg->mod_params->ant_sel == 1)
1027                        gl_bt_coexist.board_info.btdm_ant_pos =
1028                                BTC_ANTENNA_AT_AUX_PORT;
1029                else
1030                        gl_bt_coexist.board_info.btdm_ant_pos =
1031                                BTC_ANTENNA_AT_MAIN_PORT;
1032        }
1033}

The issue is that lines of code 1015-1016 and 1018-1019 are identical  
for different branches.

My question here is if one of those assignments should be modified, or  
the entire _if_ statement replaced and the function refactored?

I'd really appreciate any comment on this.

Thank you!
--
Gustavo A. R. Silva

[toc] | [next] | [standalone]


#1643724 — Re: [net-realtek-btcoexist] question about identical code for different branches

FromLarry Finger <Larry.Finger@lwfinger.net>
Date2017-05-18 03:40 +0200
SubjectRe: [net-realtek-btcoexist] question about identical code for different branches
Message-ID<tIiA2-2zt-1@gated-at.bofh.it>
In reply to#1643660
On 05/17/2017 04:52 PM, Gustavo A. R. Silva wrote:
> 
> Hello everybody,
> 
> While looking into Coverity ID 1362263 I ran into the following piece of code at 
> drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c:1000:
> 
> 1000void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
> 1001{
> 1002        if (BT_COEX_ANT_TYPE_PG == type) {
> 1003                gl_bt_coexist.board_info.pg_ant_num = ant_num;
> 1004                gl_bt_coexist.board_info.btdm_ant_num = ant_num;
> 1005                /* The antenna position:
> 1006                 * Main (default) or Aux for pgAntNum=2 && btdmAntNum =1.
> 1007                 * The antenna position should be determined by
> 1008                 * auto-detect mechanism.
> 1009                 * The following is assumed to main,
> 1010                 * and those must be modified
> 1011                 * if y auto-detect mechanism is ready
> 1012                 */
> 1013                if ((gl_bt_coexist.board_info.pg_ant_num == 2) &&
> 1014                    (gl_bt_coexist.board_info.btdm_ant_num == 1))
> 1015                        gl_bt_coexist.board_info.btdm_ant_pos =
> 1016                                                       
> BTC_ANTENNA_AT_MAIN_PORT;
> 1017                else
> 1018                        gl_bt_coexist.board_info.btdm_ant_pos =
> 1019                                                       
> BTC_ANTENNA_AT_MAIN_PORT;
> 1020        } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
> 1021                gl_bt_coexist.board_info.btdm_ant_num = ant_num;
> 1022                gl_bt_coexist.board_info.btdm_ant_pos =
> 1023                                                       
> BTC_ANTENNA_AT_MAIN_PORT;
> 1024        } else if (type == BT_COEX_ANT_TYPE_DETECTED) {
> 1025                gl_bt_coexist.board_info.btdm_ant_num = ant_num;
> 1026                if (rtlpriv->cfg->mod_params->ant_sel == 1)
> 1027                        gl_bt_coexist.board_info.btdm_ant_pos =
> 1028                                BTC_ANTENNA_AT_AUX_PORT;
> 1029                else
> 1030                        gl_bt_coexist.board_info.btdm_ant_pos =
> 1031                                BTC_ANTENNA_AT_MAIN_PORT;
> 1032        }
> 1033}
> 
> The issue is that lines of code 1015-1016 and 1018-1019 are identical for 
> different branches.
> 
> My question here is if one of those assignments should be modified, or the 
> entire _if_ statement replaced and the function refactored?
> 
> I'd really appreciate any comment on this.
> 
> Thank you!
> -- 
> Gustavo A. R. Silva

Gustavo,

Thanks for the notification. I will discuss with Realtek as to the proper fix.

Larry

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web