From 6144922e17677204cbead4ee544699af69785a84 Mon Sep 17 00:00:00 2001 From: "Jiri Slaby (SUSE)" Date: Wed, 16 Aug 2023 12:55:25 +0200 Subject: tty: tty_buffer: switch insert functions to size_t All the functions accept size_t as a size argument. They finally return the same size (or less). It is quite unexpected that they return a signed value and can confuse users to check for negative values. Instead, return the same size_t as accepted to make clear we return values >= 0, where zero in fact means failure. Signed-off-by: "Jiri Slaby (SUSE)" Link: https://lore.kernel.org/r/20230816105530.3335-6-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/tty/tty_buffer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/tty/tty_buffer.c') diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index c101b4ab737e..598891e53031 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -303,16 +303,16 @@ int tty_buffer_request_room(struct tty_port *port, size_t size) } EXPORT_SYMBOL_GPL(tty_buffer_request_room); -int __tty_insert_flip_string_flags(struct tty_port *port, const u8 *chars, - const u8 *flags, bool mutable_flags, - size_t size) +size_t __tty_insert_flip_string_flags(struct tty_port *port, const u8 *chars, + const u8 *flags, bool mutable_flags, + size_t size) { bool need_flags = mutable_flags || flags[0] != TTY_NORMAL; - int copied = 0; + size_t copied = 0; do { - int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); - int space = __tty_buffer_request_room(port, goal, need_flags); + size_t goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); + size_t space = __tty_buffer_request_room(port, goal, need_flags); struct tty_buffer *tb = port->buf.tail; if (unlikely(space == 0)) -- cgit v1.2.3