Skip to content

Commit d88c3c2

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: n_tty: simplify chars_in_buffer()
The 'if' in chars_in_buffer() is misleadingly inverted. And since the only difference is the head used for computation, cache the head using ternary operator. And use that in return directly. 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 046b44a commit d88c3c2

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/tty/n_tty.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,9 @@ static void n_tty_kick_worker(const struct tty_struct *tty)
219219
static ssize_t chars_in_buffer(const struct tty_struct *tty)
220220
{
221221
const struct n_tty_data *ldata = tty->disc_data;
222-
ssize_t n = 0;
222+
size_t head = ldata->icanon ? ldata->canon_head : ldata->commit_head;
223223

224-
if (!ldata->icanon)
225-
n = ldata->commit_head - ldata->read_tail;
226-
else
227-
n = ldata->canon_head - ldata->read_tail;
228-
return n;
224+
return head - ldata->read_tail;
229225
}
230226

231227
/**

0 commit comments

Comments
 (0)