Skip to content

Commit e30364c

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: n_tty: unify counts to size_t
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)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b9b96b2 commit e30364c

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

drivers/tty/n_tty.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,27 +1523,27 @@ static void n_tty_lookahead_flow_ctrl(struct tty_struct *tty, const u8 *cp,
15231523

15241524
static void
15251525
n_tty_receive_buf_real_raw(const struct tty_struct *tty, const u8 *cp,
1526-
int count)
1526+
size_t count)
15271527
{
15281528
struct n_tty_data *ldata = tty->disc_data;
15291529
size_t n, head;
15301530

15311531
head = MASK(ldata->read_head);
1532-
n = min_t(size_t, count, N_TTY_BUF_SIZE - head);
1532+
n = min(count, N_TTY_BUF_SIZE - head);
15331533
memcpy(read_buf_addr(ldata, head), cp, n);
15341534
ldata->read_head += n;
15351535
cp += n;
15361536
count -= n;
15371537

15381538
head = MASK(ldata->read_head);
1539-
n = min_t(size_t, count, N_TTY_BUF_SIZE - head);
1539+
n = min(count, N_TTY_BUF_SIZE - head);
15401540
memcpy(read_buf_addr(ldata, head), cp, n);
15411541
ldata->read_head += n;
15421542
}
15431543

15441544
static void
15451545
n_tty_receive_buf_raw(struct tty_struct *tty, const u8 *cp, const u8 *fp,
1546-
int count)
1546+
size_t count)
15471547
{
15481548
struct n_tty_data *ldata = tty->disc_data;
15491549
u8 flag = TTY_NORMAL;
@@ -1560,7 +1560,7 @@ n_tty_receive_buf_raw(struct tty_struct *tty, const u8 *cp, const u8 *fp,
15601560

15611561
static void
15621562
n_tty_receive_buf_closing(struct tty_struct *tty, const u8 *cp, const u8 *fp,
1563-
int count, bool lookahead_done)
1563+
size_t count, bool lookahead_done)
15641564
{
15651565
u8 flag = TTY_NORMAL;
15661566

@@ -1573,7 +1573,7 @@ n_tty_receive_buf_closing(struct tty_struct *tty, const u8 *cp, const u8 *fp,
15731573
}
15741574

15751575
static void n_tty_receive_buf_standard(struct tty_struct *tty, const u8 *cp,
1576-
const u8 *fp, int count,
1576+
const u8 *fp, size_t count,
15771577
bool lookahead_done)
15781578
{
15791579
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,
16121612
}
16131613

16141614
static void __receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp,
1615-
int count)
1615+
size_t count)
16161616
{
16171617
struct n_tty_data *ldata = tty->disc_data;
16181618
bool preops = I_ISTRIP(tty) || (I_IUCLC(tty) && L_IEXTEN(tty));
1619-
size_t la_count = min_t(size_t, ldata->lookahead_count, count);
1619+
size_t la_count = min(ldata->lookahead_count, count);
16201620

16211621
if (ldata->real_raw)
16221622
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,
16871687
*/
16881688
static size_t
16891689
n_tty_receive_buf_common(struct tty_struct *tty, const u8 *cp, const u8 *fp,
1690-
int count, bool flow)
1690+
size_t count, bool flow)
16911691
{
16921692
struct n_tty_data *ldata = tty->disc_data;
1693-
size_t rcvd = 0;
1694-
int room, n, overflow;
1693+
size_t n, rcvd = 0;
1694+
int room, overflow;
16951695

16961696
down_read(&tty->termios_rwsem);
16971697

@@ -1724,7 +1724,7 @@ n_tty_receive_buf_common(struct tty_struct *tty, const u8 *cp, const u8 *fp,
17241724
} else
17251725
overflow = 0;
17261726

1727-
n = min(count, room);
1727+
n = min_t(size_t, count, room);
17281728
if (!n)
17291729
break;
17301730

@@ -1954,9 +1954,8 @@ static inline int input_available_p(const struct tty_struct *tty, int poll)
19541954
* caller holds non-exclusive %termios_rwsem;
19551955
* read_tail published
19561956
*/
1957-
static bool copy_from_read_buf(const struct tty_struct *tty,
1958-
u8 **kbp,
1959-
size_t *nr)
1957+
static bool copy_from_read_buf(const struct tty_struct *tty, u8 **kbp,
1958+
size_t *nr)
19601959

19611960
{
19621961
struct n_tty_data *ldata = tty->disc_data;
@@ -2009,8 +2008,7 @@ static bool copy_from_read_buf(const struct tty_struct *tty,
20092008
* caller holds non-exclusive %termios_rwsem;
20102009
* read_tail published
20112010
*/
2012-
static bool canon_copy_from_read_buf(const struct tty_struct *tty,
2013-
u8 **kbp,
2011+
static bool canon_copy_from_read_buf(const struct tty_struct *tty, u8 **kbp,
20142012
size_t *nr)
20152013
{
20162014
struct n_tty_data *ldata = tty->disc_data;

0 commit comments

Comments
 (0)