Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: use min() in iterate_tty_write()

It simplifies the code. The "price" is we have to unify 'chunk' to be
size_t the same as 'count' is. But that change is actually correct.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230810091510.13006-24-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
ccc8dc00 a32a672d

+2 -6
+2 -6
drivers/tty/tty_io.c
··· 964 964 static ssize_t iterate_tty_write(struct tty_ldisc *ld, struct tty_struct *tty, 965 965 struct file *file, struct iov_iter *from) 966 966 { 967 - size_t count = iov_iter_count(from); 967 + size_t chunk, count = iov_iter_count(from); 968 968 ssize_t ret, written = 0; 969 - unsigned int chunk; 970 969 971 970 ret = tty_write_lock(tty, file->f_flags & O_NDELAY); 972 971 if (ret < 0) ··· 1009 1010 1010 1011 /* Do the write .. */ 1011 1012 for (;;) { 1012 - size_t size = count; 1013 - 1014 - if (size > chunk) 1015 - size = chunk; 1013 + size_t size = min(chunk, count); 1016 1014 1017 1015 ret = -EFAULT; 1018 1016 if (copy_from_iter(tty->write_buf, size, from) != size)