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 v2 03/14] tty: n_tty: use 'num' for writes' counts
Date: Sun, 27 Aug 2023 09:41:36 +0200 [thread overview]
Message-ID: <20230827074147.2287-4-jirislaby@kernel.org> (raw)
In-Reply-To: <20230827074147.2287-1-jirislaby@kernel.org>
We have a separate misnomer 'c' to hold the retuned value from
tty->ops->write(). Instead, use 'num' already defined on another place
(and already properly typed).
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
Notes:
[v2] use 'name' instead of 'retval' as Ilpo suggests
drivers/tty/n_tty.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index f6fa4dbdf78f..7f9fee4cf7cf 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -2335,8 +2335,7 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
{
const u8 *b = buf;
DEFINE_WAIT_FUNC(wait, woken_wake_function);
- int c;
- ssize_t retval = 0;
+ ssize_t num, retval = 0;
/* Job control check -- must be done at start (POSIX.1 7.1.1.4). */
if (L_TOSTOP(tty) && file->f_op->write_iter != redirected_tty_write) {
@@ -2362,7 +2361,7 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
}
if (O_OPOST(tty)) {
while (nr > 0) {
- ssize_t num = process_output_block(tty, b, nr);
+ num = process_output_block(tty, b, nr);
if (num < 0) {
if (num == -EAGAIN)
break;
@@ -2384,16 +2383,16 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
while (nr > 0) {
mutex_lock(&ldata->output_lock);
- c = tty->ops->write(tty, b, nr);
+ num = tty->ops->write(tty, b, nr);
mutex_unlock(&ldata->output_lock);
- if (c < 0) {
- retval = c;
+ if (num < 0) {
+ retval = num;
goto break_out;
}
- if (!c)
+ if (!num)
break;
- b += c;
- nr -= c;
+ b += num;
+ nr -= num;
}
}
if (!nr)
--
2.42.0
next prev parent reply other threads:[~2023-08-27 7:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-27 7:41 [PATCH v2 00/14] tty: n_tty: cleanup Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 01/14] tty: n_tty: make flow of n_tty_receive_buf_common() a bool Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 02/14] tty: n_tty: use output character directly Jiri Slaby (SUSE)
2023-08-27 7:41 ` Jiri Slaby (SUSE) [this message]
2023-08-27 7:41 ` [PATCH v2 04/14] tty: n_tty: use time_is_before_jiffies() in n_tty_receive_overrun() Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 05/14] tty: n_tty: make n_tty_data::num_overrun unsigned Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 06/14] tty: n_tty: use MASK() for masking out size bits Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 07/14] tty: n_tty: move canon handling to a separate function Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 08/14] tty: n_tty: move newline " Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 09/14] tty: n_tty: remove unsigned char casts from character constants Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 10/14] tty: n_tty: simplify chars_in_buffer() Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 11/14] tty: n_tty: use u8 for chars and flags Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 12/14] tty: n_tty: unify counts to size_t Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 13/14] tty: n_tty: extract ECHO_OP processing to a separate function Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 14/14] tty: n_tty: deduplicate copy code in n_tty_receive_buf_real_raw() Jiri Slaby (SUSE)
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=20230827074147.2287-4-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox