Linux EDAC development
 help / color / mirror / Atom feed
From: "Luck, Tony" <tony.luck@intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	"linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>,
	"Zhuo, Qiuxu" <qiuxu.zhuo@intel.com>
Subject: EDAC, sb_edac.c: Fix signedness bugs in *_get_ha() functions.
Date: Fri, 14 Sep 2018 13:19:05 -0700	[thread overview]
Message-ID: <20180914201905.GA30946@agluck-desk> (raw)

A static checker gave the following warnings:

drivers/edac/sb_edac.c:1030 ibridge_get_ha() warn: signedness bug returning '(-22)'
drivers/edac/sb_edac.c:1037 knl_get_ha() warn: signedness bug returning '(-22)'

Both because the functions are declared to return a "u8", but try to return
-EINVAL for the error case.

Fix by returning 0xff (since the caller doesn't look at, or pass on, the
return value).

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
 drivers/edac/sb_edac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index ada2cc93df58..199b6100846a 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -1027,14 +1027,14 @@ static u8 ibridge_get_ha(u8 bank)
 	case 9 ... 16:
 		return (bank - 9) / 4;
 	default:
-		return -EINVAL;
+		return 0xff;
 	}
 }
 
 /* Not used, but included for safety/symmetry */
 static u8 knl_get_ha(u8 bank)
 {
-	return -EINVAL;
+	return 0xff;
 }
 
 static u64 haswell_get_tolm(struct sbridge_pvt *pvt)

             reply	other threads:[~2018-09-14 20:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-14 20:19 Luck, Tony [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-09-15 10:21 EDAC, sb_edac.c: Fix signedness bugs in *_get_ha() functions Borislav Petkov

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=20180914201905.GA30946@agluck-desk \
    --to=tony.luck@intel.com \
    --cc=bp@alien8.de \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=qiuxu.zhuo@intel.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