From: Jiri Slaby <jirislaby@kernel.org>
To: Mohammad Mahfooz <mohammadmahfoozpersonal@gmail.com>
Cc: alexander.vorwerk@stud.uni-goettingen.de,
gregkh@linuxfoundation.org, ilpo.jarvinen@linux.intel.com,
johan@kernel.org, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: jsm: Change n to unsigned int
Date: Tue, 21 Feb 2023 07:07:42 +0100 [thread overview]
Message-ID: <89e50f2f-8881-097d-bb47-7d44cafb2e2e@kernel.org> (raw)
In-Reply-To: <20230221010339.3032-1-mohammadmahfoozpersonal@gmail.com>
On 21. 02. 23, 2:03, Mohammad Mahfooz wrote:
> Change n to an unsigned int and remove casts from min()s.
>
> Signed-off-by: Mohammad Mahfooz <mohammadmahfoozpersonal@gmail.com>
> ---
> drivers/tty/serial/jsm/jsm_neo.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
> index 4cce1e423b06..394121870436 100644
> --- a/drivers/tty/serial/jsm/jsm_neo.c
> +++ b/drivers/tty/serial/jsm/jsm_neo.c
> @@ -277,7 +277,7 @@ static void neo_copy_data_from_uart_to_queue(struct jsm_channel *ch)
> int qleft = 0;
> u8 linestatus = 0;
> u8 error_mask = 0;
> - int n = 0;
> + u32 n = 0;
> int total = 0;
> u16 head;
> u16 tail;
> @@ -342,15 +342,15 @@ static void neo_copy_data_from_uart_to_queue(struct jsm_channel *ch)
> break;
>
> /* Make sure we don't go over the end of our queue */
> - n = min(((u32) total), (RQUEUESIZE - (u32) head));
> + n = min(total, RQUEUESIZE - head);
This should warn now, right as total is signed too, right? And qleft.
All should likely be unsigned. And the computation of qleft would need
to be changed.
It's not as easy as this.
>
> /*
> * Cut down n even further if needed, this is to fix
> * a problem with memcpy_fromio() with the Neo on the
> * IBM pSeries platform.
> - * 15 bytes max appears to be the magic number.
> + * 12 bytes max appears to be the magic number.
> */
> - n = min_t(u32, n, 12);
> + n = min(n, 12U);
>
> /*
> * Since we are grabbing the linestatus register, which
--
js
suse labs
next prev parent reply other threads:[~2023-02-21 6:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-19 20:53 [PATCH] serial: jsm: Use min_t instead of min Mohammad Mahfooz
2023-02-20 11:52 ` Jiri Slaby
2023-02-21 1:03 ` [PATCH] serial: jsm: Change n to unsigned int Mohammad Mahfooz
2023-02-21 6:07 ` Jiri Slaby [this message]
2023-02-21 12:48 ` [PATCH] serial: jsm: Use min_t instead of min David Laight
2023-02-21 13:17 ` Ilpo Järvinen
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=89e50f2f-8881-097d-bb47-7d44cafb2e2e@kernel.org \
--to=jirislaby@kernel.org \
--cc=alexander.vorwerk@stud.uni-goettingen.de \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=mohammadmahfoozpersonal@gmail.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;
as well as URLs for NNTP newsgroup(s).