summaryrefslogtreecommitdiff
path: root/drivers/tty
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@kernel.org>2023-07-12 09:42:14 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-07-25 20:19:39 +0300
commitf6f847ff8d6662977fd7f7199152b87ef029e704 (patch)
tree1c04ed5dcac61fd4da378092cbf2b33a488c8808 /drivers/tty
parentb30a3d396b4c4fccc73a4922d594bb589afb5bee (diff)
downloadlinux-f6f847ff8d6662977fd7f7199152b87ef029e704.tar.xz
n_tty: simplify and sanitize zero_buffer()
* Make 'tty' parameter const as we only look at tty flags here. * Make 'size' parameter of size_t type as everyone passes that and memset() (the consumer) expects size_t too. So be consistent. * Remove redundant local variables, place the content directly to the 'if'. * Use 0 instead of 0x00 in memset(). The former is more obvious. No functional changes expected. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230712064216.12150-3-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/n_tty.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 1599012f20c8..c1859ae263eb 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -158,13 +158,10 @@ static inline unsigned char *echo_buf_addr(struct n_tty_data *ldata, size_t i)
}
/* If we are not echoing the data, perhaps this is a secret so erase it */
-static void zero_buffer(struct tty_struct *tty, u8 *buffer, int size)
+static void zero_buffer(const struct tty_struct *tty, u8 *buffer, size_t size)
{
- bool icanon = !!L_ICANON(tty);
- bool no_echo = !L_ECHO(tty);
-
- if (icanon && no_echo)
- memset(buffer, 0x00, size);
+ if (L_ICANON(tty) && !L_ECHO(tty))
+ memset(buffer, 0, size);
}
static void tty_copy(struct tty_struct *tty, void *to, size_t tail, size_t n)