All of lore.kernel.org
 help / color / mirror / Atom feed
From: der.herr@hofr.at (Nicholas Mc Guire)
To: kernelnewbies@lists.kernelnewbies.org
Subject: if/else block default coding style question
Date: Sat, 8 Oct 2016 10:40:37 +0000	[thread overview]
Message-ID: <20161008104037.GA493@osadl.at> (raw)


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

             reply	other threads:[~2016-10-08 10:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-08 10:40 Nicholas Mc Guire [this message]
2016-10-08 14:58 ` if/else block default coding style question 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161008104037.GA493@osadl.at \
    --to=der.herr@hofr.at \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.