Skip to contentSkip to conversation

8250_men_mcb: Fix unsigned comparison with less than zero

PATCH In review Jiapeng Chong 2 participants 2 messages Aug 3, 2023 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 8250_men_mcb: Fix unsigned comparison with less than zero

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.

---
 drivers/tty/serial/8250/8250_men_mcb.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250_men_mcb.c +5 -3
index 5f301195575d..c27c52d18dfa 100644
@@ -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]);
 	}
 
Signature · 1 line
2.20.1.7.g153144c
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Jiapeng Chong

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko