if/else block default coding style question

Nicholas Mc Guire der.herr at hofr.at
Sat Oct 8 06:40:37 EDT 2016


Hi !

 There are quite a few places (roughly 90) in the kernel where an 
 if/else if/else block repeats the last "case" presumably as 
 default e.g.  drivers/net/wireless/realtek/rtlwifi/rtl8192c/dm_common.c

   if ((rtlpcipriv->bt_coexist.bt_service == BT_BUSY) &&
       (rtlpcipriv->bt_coexist.bt_rssi_state &
        BT_RSSI_STATE_NORMAL_POWER)) {
           rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG, 0xa0);
   } else if ((rtlpcipriv->bt_coexist.bt_service ==
               BT_OTHER_ACTION) && (rtlpriv->mac80211.mode <
               WIRELESS_MODE_N_24G) &&
               (rtlpcipriv->bt_coexist.bt_rssi_state &
               BT_RSSI_STATE_SPECIAL_LOW)) {
           rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG, 0xa0);
   } else if (rtlpcipriv->bt_coexist.bt_service == BT_PAN) {
           rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG, tmp1byte);
   } else {
           rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG, tmp1byte);
   }

 with the last else if and else being identical.
 So the question is if this is accepted coding style (notably 
 without a coment) or if things like this should be flagged.

 I personally find this irritating as (without a comment) it is hard to say
 if this is a trivial type -> missed case, or if this is
 intended as a default behavior.

 So - before starting to generate a series of patches - should stuff like 
 this be flagged ?

thx!
hofrat



More information about the Kernelnewbies mailing list