Netdev List
 help / color / mirror / Atom feed
From: Colin Ian King <colin.king@canonical.com>
To: Siva Reddy <siva.kallam@samsung.com>,
	Vipul Pandya <vipul.pandya@samsung.com>,
	Girish K S <ks.giri@samsung.com>,
	Byungho An <bh74.an@samsung.com>,
	"David S. Miller" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: net: sxgbe: issue with case statement in sxgbe_mtl_init
Date: Wed, 13 Feb 2019 11:15:55 +0000	[thread overview]
Message-ID: <c16dfcf4-4402-cd34-c40c-4dd5bd5912c4@canonical.com> (raw)

Hi,

Static analysis with CoverityScan has detected two switch statements
where all of the case statements are deadcode.  The values being
switched on are masked and these will never match any of the values
being checked, so this clearly is an error.

Function sxgbe_mtl_init, drivers/net/ethernet/samsung/sxgbe/sxgbe_mtl.c:

 31        /* ETS Algorith */
 32        switch (etsalg & SXGBE_MTL_OPMODE_ESTMASK) {

   dead_error_condition: The switch value etsalg & 3U cannot be 4294967199U.
   CID 1195543 (#1 of 3): Logically dead code

 33        case ETS_WRR:
 34                reg_val &= ETS_WRR;
 35                break;

 dead_error_condition: The switch value etsalg & 3U cannot be 32U.
   CID 1195543 (#2 of 3): Logically dead code

 36        case ETS_WFQ:
 37                reg_val |= ETS_WFQ;
 38                break;

  dead_error_condition: The switch value etsalg & 3U cannot be 64U.
   CID 1195543 (#3 of 3): Logically dead code

 39        case ETS_DWRR:
 40                reg_val |= ETS_DWRR;
 41                break;
 42        }
 43        writel(reg_val, ioaddr + SXGBE_MTL_OP_MODE_REG);
 44

And also in the following switch statement:

 45        switch (raa & SXGBE_MTL_OPMODE_RAAMASK) {

 dead_error_condition: The switch value raa & 1U cannot be 4294967291U.
   CID 1195544 (#1 of 2): Logically dead code

 46        case RAA_SP:
 47                reg_val &= RAA_SP;
 48                break;

  dead_error_condition: The switch value raa & 1U cannot be 4U.
   CID 1195544 (#2 of 2): Logically dead code

 49        case RAA_WSP:
 50                reg_val |= RAA_WSP;
 51                break;
 52        }
 53        writel(reg_val, ioaddr + SXGBE_MTL_OP_MODE_REG);
 54}

Colin

                 reply	other threads:[~2019-02-13 11:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=c16dfcf4-4402-cd34-c40c-4dd5bd5912c4@canonical.com \
    --to=colin.king@canonical.com \
    --cc=bh74.an@samsung.com \
    --cc=davem@davemloft.net \
    --cc=ks.giri@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=siva.kallam@samsung.com \
    --cc=vipul.pandya@samsung.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox