mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2025-12-09 18:26:58 +00:00
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>
This commit is contained in:
parent
a32a672dc5
commit
ccc8dc00a2
@ -964,9 +964,8 @@ int tty_write_lock(struct tty_struct *tty, bool ndelay)
|
|||||||
static ssize_t iterate_tty_write(struct tty_ldisc *ld, struct tty_struct *tty,
|
static ssize_t iterate_tty_write(struct tty_ldisc *ld, struct tty_struct *tty,
|
||||||
struct file *file, struct iov_iter *from)
|
struct file *file, struct iov_iter *from)
|
||||||
{
|
{
|
||||||
size_t count = iov_iter_count(from);
|
size_t chunk, count = iov_iter_count(from);
|
||||||
ssize_t ret, written = 0;
|
ssize_t ret, written = 0;
|
||||||
unsigned int chunk;
|
|
||||||
|
|
||||||
ret = tty_write_lock(tty, file->f_flags & O_NDELAY);
|
ret = tty_write_lock(tty, file->f_flags & O_NDELAY);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -1010,10 +1009,7 @@ static ssize_t iterate_tty_write(struct tty_ldisc *ld, struct tty_struct *tty,
|
|||||||
|
|
||||||
/* Do the write .. */
|
/* Do the write .. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
size_t size = count;
|
size_t size = min(chunk, count);
|
||||||
|
|
||||||
if (size > chunk)
|
|
||||||
size = chunk;
|
|
||||||
|
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
if (copy_from_iter(tty->write_buf, size, from) != size)
|
if (copy_from_iter(tty->write_buf, size, from) != size)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user