tty: return tty->name directly from tty_name

All users of tty_name pass the return value (the provided buffer) to
some printf-like function. We can thus avoid the strcpy and, more
importantly, later remove the buf parameter completely, eliminating
the need for some 64 byte stack buffers.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Rasmus Villemoes 2015-03-31 15:55:58 +02:00 committed by Greg Kroah-Hartman
parent 1d6b98774c
commit 917162c936

View File

@ -235,7 +235,7 @@ static void tty_del_file(struct file *file)
/**
* tty_name - return tty naming
* @tty: tty structure
* @buf: buffer for output
* @buf: unused
*
* Convert a tty structure into a name. The name reflects the kernel
* naming policy and if udev is in use may not reflect user space
@ -246,10 +246,8 @@ static void tty_del_file(struct file *file)
const char *tty_name(const struct tty_struct *tty, char *buf)
{
if (!tty) /* Hmm. NULL pointer. That's fun. */
strcpy(buf, "NULL tty");
else
strcpy(buf, tty->name);
return buf;
return "NULL tty";
return tty->name;
}
EXPORT_SYMBOL(tty_name);