From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754952AbbCaN5P (ORCPT ); Tue, 31 Mar 2015 09:57:15 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:34714 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754825AbbCaN41 (ORCPT ); Tue, 31 Mar 2015 09:56:27 -0400 From: Rasmus Villemoes To: Greg Kroah-Hartman , Jiri Slaby Cc: Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] tty: constify return type of tty_name Date: Tue, 31 Mar 2015 15:55:57 +0200 Message-Id: <1427810160-15779-2-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1427810160-15779-1-git-send-email-linux@rasmusvillemoes.dk> References: <1427810160-15779-1-git-send-email-linux@rasmusvillemoes.dk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All users of tty_name pass the result directly to a printf-like function. This means we can actually let tty_name return the literal "NULL tty" or tty->name directly, avoiding the strcpy and a lot of medium-sized stack buffers. In preparation for that, make the return type const char*. While at it, we can also constify the tty parameter. Signed-off-by: Rasmus Villemoes --- drivers/tty/tty_io.c | 2 +- include/linux/tty.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 2bb4dfc02873..5d4a9fd7510a 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -243,7 +243,7 @@ static void tty_del_file(struct file *file) * Locking: none */ -char *tty_name(struct tty_struct *tty, char *buf) +const char *tty_name(const struct tty_struct *tty, char *buf) { if (!tty) /* Hmm. NULL pointer. That's fun. */ strcpy(buf, "NULL tty"); diff --git a/include/linux/tty.h b/include/linux/tty.h index 358a337af598..8771cc4faf9f 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -421,7 +421,7 @@ static inline struct tty_struct *tty_kref_get(struct tty_struct *tty) extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode, const char *routine); -extern char *tty_name(struct tty_struct *tty, char *buf); +extern const char *tty_name(const struct tty_struct *tty, char *buf); extern void tty_wait_until_sent(struct tty_struct *tty, long timeout); extern int tty_check_change(struct tty_struct *tty); extern void __stop_tty(struct tty_struct *tty); -- 2.1.3