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 ssize_t for iterate_tty_read() returned type

tty_read() is supposed to return ssize_t. It takes the return value from
iterate_tty_read(). That currently returns int. On the top of that,
iterate_tty_write() already returns ssize_t. So switch
iterate_tty_read() to ssize_t too, so that all three are consistent.

This means 'i' in tty_read() changes its type too. And while changing
that, rename this generic 'i' to more dedicated 'ret'.

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

authored by

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

+8 -8
+8 -8
drivers/tty/tty_io.c
··· 843 843 * data or clears the cookie. The cookie may be something that the 844 844 * ldisc maintains state for and needs to free. 845 845 */ 846 - static int iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty, 847 - struct file *file, struct iov_iter *to) 846 + static ssize_t iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty, 847 + struct file *file, struct iov_iter *to) 848 848 { 849 - int retval = 0; 850 849 void *cookie = NULL; 851 850 unsigned long offset = 0; 852 851 char kernel_buf[64]; 852 + ssize_t retval = 0; 853 853 size_t count = iov_iter_count(to); 854 854 855 855 do { ··· 912 912 */ 913 913 static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to) 914 914 { 915 - int i; 916 915 struct file *file = iocb->ki_filp; 917 916 struct inode *inode = file_inode(file); 918 917 struct tty_struct *tty = file_tty(file); 919 918 struct tty_ldisc *ld; 919 + ssize_t ret; 920 920 921 921 if (tty_paranoia_check(tty, inode, "tty_read")) 922 922 return -EIO; ··· 929 929 ld = tty_ldisc_ref_wait(tty); 930 930 if (!ld) 931 931 return hung_up_tty_read(iocb, to); 932 - i = -EIO; 932 + ret = -EIO; 933 933 if (ld->ops->read) 934 - i = iterate_tty_read(ld, tty, file, to); 934 + ret = iterate_tty_read(ld, tty, file, to); 935 935 tty_ldisc_deref(ld); 936 936 937 - if (i > 0) 937 + if (ret > 0) 938 938 tty_update_time(tty, false); 939 939 940 - return i; 940 + return ret; 941 941 } 942 942 943 943 void tty_write_unlock(struct tty_struct *tty)