public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Purva Yeshi <purvayeshi550@gmail.com>
To: arnd@arndb.de, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, Purva Yeshi <purvayeshi550@gmail.com>
Subject: [PATCH] char: mwave: smapi: Make usSmapiOK signed to fix warning
Date: Thu, 10 Apr 2025 02:49:29 +0530	[thread overview]
Message-ID: <20250409211929.213360-1-purvayeshi550@gmail.com> (raw)

Fix Smatch-detected warning:
drivers/char/mwave/smapi.c:69 smapi_request() warn:
assigning (-5) to unsigned variable 'usSmapiOK'

Assigning a negative value (-EIO, which is -5) to an unsigned short
(usSmapiOK) causes a Smatch warning because negative values cannot
be correctly represented in an unsigned type, leading to unexpected
behavior.

Change the type of usSmapiOK from unsigned short to short to allow
storing negative values like -EIO without causing a type mismatch or
logic error.

Signed-off-by: Purva Yeshi <purvayeshi550@gmail.com>
---
 drivers/char/mwave/smapi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/mwave/smapi.c b/drivers/char/mwave/smapi.c
index f8d79d393b69..37da1339357e 100644
--- a/drivers/char/mwave/smapi.c
+++ b/drivers/char/mwave/smapi.c
@@ -66,7 +66,7 @@ static int smapi_request(unsigned short inBX, unsigned short inCX,
 	unsigned short myoutDX = 5, *pmyoutDX = &myoutDX;
 	unsigned short myoutDI = 6, *pmyoutDI = &myoutDI;
 	unsigned short myoutSI = 7, *pmyoutSI = &myoutSI;
-	unsigned short usSmapiOK = -EIO, *pusSmapiOK = &usSmapiOK;
+	short usSmapiOK = -EIO, *pusSmapiOK = &usSmapiOK;
 	unsigned int inBXCX = (inBX << 16) | inCX;
 	unsigned int inDISI = (inDI << 16) | inSI;
 	int retval = 0;
-- 
2.34.1


             reply	other threads:[~2025-04-09 21:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09 21:19 Purva Yeshi [this message]
2025-04-15 14:52 ` [PATCH] char: mwave: smapi: Make usSmapiOK signed to fix warning Greg KH
2025-04-17  5:59   ` Purva Yeshi

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=20250409211929.213360-1-purvayeshi550@gmail.com \
    --to=purvayeshi550@gmail.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox