linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 8250_men_mcb: Fix unsigned comparison with less than zero
@ 2023-08-03  8:47 Jiapeng Chong
  2023-08-03 11:58 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2023-08-03  8:47 UTC (permalink / raw)
  To: gregkh
  Cc: andriy.shevchenko, linux-serial, linux-kernel, Jiapeng Chong,
	Abaci Robot

The data->line[i] is defined as unsigned int type, if(data->line[i] < 0)
is invalid, so replace data->line[i] with res.

./drivers/tty/serial/8250/8250_men_mcb.c:223:6-19: WARNING: Unsigned expression compared with zero: data->line[i] < 0.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=6088
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 drivers/tty/serial/8250/8250_men_mcb.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c b/drivers/tty/serial/8250/8250_men_mcb.c
index 5f301195575d..c27c52d18dfa 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -222,11 +222,13 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
 					    + data->offset[i];
 
 		/* ok, register the port */
-		data->line[i] = serial8250_register_8250_port(&uart);
-		if (data->line[i] < 0) {
+		res = serial8250_register_8250_port(&uart);
+		if (res < 0) {
 			dev_err(&mdev->dev, "unable to register UART port\n");
-			return data->line[i];
+			return res;
 		}
+
+		data->line[i] = res;
 		dev_info(&mdev->dev, "found MCB UART: ttyS%d\n", data->line[i]);
 	}
 
-- 
2.20.1.7.g153144c


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

* Re: [PATCH] 8250_men_mcb: Fix unsigned comparison with less than zero
  2023-08-03  8:47 [PATCH] 8250_men_mcb: Fix unsigned comparison with less than zero Jiapeng Chong
@ 2023-08-03 11:58 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2023-08-03 11:58 UTC (permalink / raw)
  To: Jiapeng Chong; +Cc: gregkh, linux-serial, linux-kernel, Abaci Robot

On Thu, Aug 03, 2023 at 04:47:53PM +0800, Jiapeng Chong wrote:
> The data->line[i] is defined as unsigned int type, if(data->line[i] < 0)
> is invalid, so replace data->line[i] with res.
> 
> ./drivers/tty/serial/8250/8250_men_mcb.c:223:6-19: WARNING: Unsigned expression compared with zero: data->line[i] < 0.

Having

 WARNING: Unsigned expression compared with zero: data->line[i] < 0.

is enough.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2023-08-03 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03  8:47 [PATCH] 8250_men_mcb: Fix unsigned comparison with less than zero Jiapeng Chong
2023-08-03 11:58 ` Andy Shevchenko

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).