kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* if/else block default coding style question
@ 2016-10-08 10:40 Nicholas Mc Guire
  2016-10-08 14:58 ` Valdis.Kletnieks at vt.edu
  0 siblings, 1 reply; 6+ messages in thread
From: Nicholas Mc Guire @ 2016-10-08 10:40 UTC (permalink / raw)
  To: kernelnewbies


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-10-08 19:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-08 10:40 if/else block default coding style question Nicholas Mc Guire
2016-10-08 14:58 ` Valdis.Kletnieks at vt.edu
2016-10-08 15:10   ` Robert P. J. Day
2016-10-08 15:23     ` Nicholas Mc Guire
2016-10-08 15:19   ` Nicholas Mc Guire
2016-10-08 19:40     ` Valdis.Kletnieks at vt.edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).