* [PATCH -next] 8250_men_mcb: Fix unsigned expression compared with zero
@ 2023-08-03 14:20 Li Zetao
2023-08-04 5:07 ` Jiri Slaby
2023-08-04 5:37 ` Andy Shevchenko
0 siblings, 2 replies; 4+ messages in thread
From: Li Zetao @ 2023-08-03 14:20 UTC (permalink / raw)
To: gregkh, jirislaby, jorge.sanjuangarcia, JoseJavier.Rodriguez
Cc: lizetao1, yangyingliang, andriy.shevchenko, linux-serial
There is a warning reported by coccinelle:
./drivers/tty/serial/8250/8250_men_mcb.c:226:6-19: WARNING:
Unsigned expression compared with zero: data -> line [ i ] < 0
The array "line" of serial_8250_men_mcb_data is used to record the
registered serial port. When register a port failed, it will return
an error code, but the type of "line" is "unsigned int", causing
the error code to reverse. Modify the type of "data -> line" to solve
this problem.
Fixes: 2554e6ba28a2 ("8250_men_mcb: Read num ports from register data.")
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
drivers/tty/serial/8250/8250_men_mcb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_men_mcb.c b/drivers/tty/serial/8250/8250_men_mcb.c
index 5f301195575d..14cf6011a002 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -46,7 +46,7 @@
struct serial_8250_men_mcb_data {
int num_ports;
- unsigned int line[MAX_PORTS];
+ int line[MAX_PORTS];
unsigned int offset[MAX_PORTS];
};
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH -next] 8250_men_mcb: Fix unsigned expression compared with zero
2023-08-03 14:20 [PATCH -next] 8250_men_mcb: Fix unsigned expression compared with zero Li Zetao
@ 2023-08-04 5:07 ` Jiri Slaby
2023-08-04 6:36 ` Andy Shevchenko
2023-08-04 5:37 ` Andy Shevchenko
1 sibling, 1 reply; 4+ messages in thread
From: Jiri Slaby @ 2023-08-04 5:07 UTC (permalink / raw)
To: Li Zetao, gregkh, jorge.sanjuangarcia, JoseJavier.Rodriguez
Cc: yangyingliang, andriy.shevchenko, linux-serial
On 03. 08. 23, 16:20, Li Zetao wrote:
> There is a warning reported by coccinelle:
>
> ./drivers/tty/serial/8250/8250_men_mcb.c:226:6-19: WARNING:
> Unsigned expression compared with zero: data -> line [ i ] < 0
>
> The array "line" of serial_8250_men_mcb_data is used to record the
> registered serial port. When register a port failed, it will return
> an error code, but the type of "line" is "unsigned int", causing
> the error code to reverse. Modify the type of "data -> line" to solve
> this problem.
>
> Fixes: 2554e6ba28a2 ("8250_men_mcb: Read num ports from register data.")
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> ---
> drivers/tty/serial/8250/8250_men_mcb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_men_mcb.c b/drivers/tty/serial/8250/8250_men_mcb.c
> index 5f301195575d..14cf6011a002 100644
> --- a/drivers/tty/serial/8250/8250_men_mcb.c
> +++ b/drivers/tty/serial/8250/8250_men_mcb.c
> @@ -46,7 +46,7 @@
>
> struct serial_8250_men_mcb_data {
> int num_ports;
> - unsigned int line[MAX_PORTS];
> + int line[MAX_PORTS];
LGTM
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
But I wonder why this didn't emit a warning:
dev_info(&mdev->dev, "found MCB UART: ttyS%d\n", data->line[i]);
I.e. %d for uint?
thanks,
--
js
suse labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] 8250_men_mcb: Fix unsigned expression compared with zero
2023-08-03 14:20 [PATCH -next] 8250_men_mcb: Fix unsigned expression compared with zero Li Zetao
2023-08-04 5:07 ` Jiri Slaby
@ 2023-08-04 5:37 ` Andy Shevchenko
1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2023-08-04 5:37 UTC (permalink / raw)
To: Li Zetao
Cc: gregkh, jirislaby, jorge.sanjuangarcia, JoseJavier.Rodriguez,
yangyingliang, linux-serial
On Thu, Aug 03, 2023 at 10:20:53PM +0800, Li Zetao wrote:
> There is a warning reported by coccinelle:
>
> ./drivers/tty/serial/8250/8250_men_mcb.c:226:6-19: WARNING:
> Unsigned expression compared with zero: data -> line [ i ] < 0
>
> The array "line" of serial_8250_men_mcb_data is used to record the
> registered serial port. When register a port failed, it will return
> an error code, but the type of "line" is "unsigned int", causing
> the error code to reverse. Modify the type of "data -> line" to solve
> this problem.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] 8250_men_mcb: Fix unsigned expression compared with zero
2023-08-04 5:07 ` Jiri Slaby
@ 2023-08-04 6:36 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2023-08-04 6:36 UTC (permalink / raw)
To: Jiri Slaby
Cc: Li Zetao, gregkh, jorge.sanjuangarcia, JoseJavier.Rodriguez,
yangyingliang, linux-serial
On Fri, Aug 04, 2023 at 07:07:06AM +0200, Jiri Slaby wrote:
> On 03. 08. 23, 16:20, Li Zetao wrote:
...
> But I wonder why this didn't emit a warning:
> dev_info(&mdev->dev, "found MCB UART: ttyS%d\n", data->line[i]);
>
> I.e. %d for uint?
Do we have this anywhere enabled -Wformat-signedness?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-04 6:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03 14:20 [PATCH -next] 8250_men_mcb: Fix unsigned expression compared with zero Li Zetao
2023-08-04 5:07 ` Jiri Slaby
2023-08-04 6:36 ` Andy Shevchenko
2023-08-04 5:37 ` 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).