From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
To: gregkh@linuxfoundation.org
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Subject: [PATCH 12/14] tty: n_tty: unify counts to size_t
Date: Wed, 16 Aug 2023 12:58:20 +0200 [thread overview]
Message-ID: <20230816105822.3685-17-jirislaby@kernel.org> (raw)
In-Reply-To: <20230816105822.3685-1-jirislaby@kernel.org>
Some count types are already 'size_t' for a long time. Some were
switched to 'size_t' recently. Unify the rest with those now.
This allows for some min_t()s to become min()s. And make one min()
an explicit min_t() as we are comparing signed 'room' to unsigned
'count'.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
drivers/tty/n_tty.c | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 4c2f77996ad3..11becd2dda2d 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1523,27 +1523,27 @@ static void n_tty_lookahead_flow_ctrl(struct tty_struct *tty, const u8 *cp,
static void
n_tty_receive_buf_real_raw(const struct tty_struct *tty, const u8 *cp,
- int count)
+ size_t count)
{
struct n_tty_data *ldata = tty->disc_data;
size_t n, head;
head = MASK(ldata->read_head);
- n = min_t(size_t, count, N_TTY_BUF_SIZE - head);
+ n = min(count, N_TTY_BUF_SIZE - head);
memcpy(read_buf_addr(ldata, head), cp, n);
ldata->read_head += n;
cp += n;
count -= n;
head = MASK(ldata->read_head);
- n = min_t(size_t, count, N_TTY_BUF_SIZE - head);
+ n = min(count, N_TTY_BUF_SIZE - head);
memcpy(read_buf_addr(ldata, head), cp, n);
ldata->read_head += n;
}
static void
n_tty_receive_buf_raw(struct tty_struct *tty, const u8 *cp, const u8 *fp,
- int count)
+ size_t count)
{
struct n_tty_data *ldata = tty->disc_data;
u8 flag = TTY_NORMAL;
@@ -1560,7 +1560,7 @@ n_tty_receive_buf_raw(struct tty_struct *tty, const u8 *cp, const u8 *fp,
static void
n_tty_receive_buf_closing(struct tty_struct *tty, const u8 *cp, const u8 *fp,
- int count, bool lookahead_done)
+ size_t count, bool lookahead_done)
{
u8 flag = TTY_NORMAL;
@@ -1573,7 +1573,7 @@ n_tty_receive_buf_closing(struct tty_struct *tty, const u8 *cp, const u8 *fp,
}
static void n_tty_receive_buf_standard(struct tty_struct *tty, const u8 *cp,
- const u8 *fp, int count,
+ const u8 *fp, size_t count,
bool lookahead_done)
{
struct n_tty_data *ldata = tty->disc_data;
@@ -1612,11 +1612,11 @@ static void n_tty_receive_buf_standard(struct tty_struct *tty, const u8 *cp,
}
static void __receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp,
- int count)
+ size_t count)
{
struct n_tty_data *ldata = tty->disc_data;
bool preops = I_ISTRIP(tty) || (I_IUCLC(tty) && L_IEXTEN(tty));
- size_t la_count = min_t(size_t, ldata->lookahead_count, count);
+ size_t la_count = min(ldata->lookahead_count, count);
if (ldata->real_raw)
n_tty_receive_buf_real_raw(tty, cp, count);
@@ -1687,11 +1687,11 @@ static void __receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp,
*/
static size_t
n_tty_receive_buf_common(struct tty_struct *tty, const u8 *cp, const u8 *fp,
- int count, bool flow)
+ size_t count, bool flow)
{
struct n_tty_data *ldata = tty->disc_data;
- size_t rcvd = 0;
- int room, n, overflow;
+ size_t n, rcvd = 0;
+ int room, overflow;
down_read(&tty->termios_rwsem);
@@ -1724,7 +1724,7 @@ n_tty_receive_buf_common(struct tty_struct *tty, const u8 *cp, const u8 *fp,
} else
overflow = 0;
- n = min(count, room);
+ n = min_t(size_t, count, room);
if (!n)
break;
@@ -1954,9 +1954,8 @@ static inline int input_available_p(const struct tty_struct *tty, int poll)
* caller holds non-exclusive %termios_rwsem;
* read_tail published
*/
-static bool copy_from_read_buf(const struct tty_struct *tty,
- u8 **kbp,
- size_t *nr)
+static bool copy_from_read_buf(const struct tty_struct *tty, u8 **kbp,
+ size_t *nr)
{
struct n_tty_data *ldata = tty->disc_data;
@@ -2009,8 +2008,7 @@ static bool copy_from_read_buf(const struct tty_struct *tty,
* caller holds non-exclusive %termios_rwsem;
* read_tail published
*/
-static bool canon_copy_from_read_buf(const struct tty_struct *tty,
- u8 **kbp,
+static bool canon_copy_from_read_buf(const struct tty_struct *tty, u8 **kbp,
size_t *nr)
{
struct n_tty_data *ldata = tty->disc_data;
--
2.41.0
next prev parent reply other threads:[~2023-08-16 11:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-16 10:58 [PATCH 00/14] tty: n_tty: cleanup Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 1/4] n_tty: drop fp from n_tty_receive_buf_real_raw() Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 01/14] tty: n_tty: make flow of n_tty_receive_buf_common() a bool Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 2/4] n_tty: simplify and sanitize zero_buffer() Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 02/14] tty: n_tty: use output character directly Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 3/4] n_tty: pass ldata to canon_skip_eof() directly Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 03/14] tty: n_tty: use 'retval' for writes' retvals Jiri Slaby (SUSE)
2023-08-16 14:21 ` Ilpo Järvinen
2023-08-16 10:58 ` [PATCH 4/4] n_tty: make many tty parameters const Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 04/14] tty: n_tty: use time_is_before_jiffies() in n_tty_receive_overrun() Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 05/14] tty: n_tty: make n_tty_data::num_overrun unsigned Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 06/14] tty: n_tty: use MASK() for masking out size bits Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 07/14] tty: n_tty: move canon handling to a separate function Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 08/14] tty: n_tty: move newline " Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 09/14] tty: n_tty: remove unsigned char casts from character constants Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 10/14] tty: n_tty: simplify chars_in_buffer() Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 11/14] tty: n_tty: use u8 for chars and flags Jiri Slaby (SUSE)
2023-08-16 10:58 ` Jiri Slaby (SUSE) [this message]
2023-08-16 10:58 ` [PATCH 13/14] tty: n_tty: extract ECHO_OP processing to a separate function Jiri Slaby (SUSE)
2023-08-16 10:58 ` [PATCH 14/14] tty: n_tty: deduplicate copy code in n_tty_receive_buf_real_raw() Jiri Slaby (SUSE)
2023-08-16 11:02 ` [PATCH 00/14] tty: n_tty: cleanup Jiri Slaby
2023-08-16 11:20 ` Greg KH
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=20230816105822.3685-17-jirislaby@kernel.org \
--to=jirislaby@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.