tty: remove buf parameter from tty_name()

tty_name no longer uses the buf parameter, so remove it along with all
the 64 byte stack buffers that used to be passed in.

Mostly generated by the coccinelle script

@depends on patch@
identifier buf;
constant C;
expression tty;
@@
- char buf[C];
  <+...
- tty_name(tty, buf)
+ tty_name(tty)
  ...+>

allmodconfig compiles, so I'm fairly confident the stack buffers
weren't used for other purposes as well.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Rasmus Villemoes 2015-03-31 15:55:59 +02:00 committed by Greg Kroah-Hartman
parent 917162c936
commit 429b474990
11 changed files with 28 additions and 57 deletions

View File

@ -167,7 +167,6 @@ static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, u
{ {
struct serport *serport = (struct serport*) tty->disc_data; struct serport *serport = (struct serport*) tty->disc_data;
struct serio *serio; struct serio *serio;
char name[64];
if (test_and_set_bit(SERPORT_BUSY, &serport->flags)) if (test_and_set_bit(SERPORT_BUSY, &serport->flags))
return -EBUSY; return -EBUSY;
@ -177,7 +176,7 @@ static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, u
return -ENOMEM; return -ENOMEM;
strlcpy(serio->name, "Serial port", sizeof(serio->name)); strlcpy(serio->name, "Serial port", sizeof(serio->name));
snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", tty_name(tty, name)); snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", tty_name(tty));
serio->id = serport->id; serio->id = serport->id;
serio->id.type = SERIO_RS232; serio->id.type = SERIO_RS232;
serio->write = serport_serio_write; serio->write = serport_serio_write;
@ -187,7 +186,7 @@ static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, u
serio->dev.parent = tty->dev; serio->dev.parent = tty->dev;
serio_register_port(serport->serio); serio_register_port(serport->serio);
printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty, name)); printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty));
wait_event_interruptible(serport->wait, test_bit(SERPORT_DEAD, &serport->flags)); wait_event_interruptible(serport->wait, test_bit(SERPORT_DEAD, &serport->flags));
serio_unregister_port(serport->serio); serio_unregister_port(serport->serio);

View File

@ -966,9 +966,7 @@ static void rs_throttle(struct tty_struct * tty)
struct serial_state *info = tty->driver_data; struct serial_state *info = tty->driver_data;
unsigned long flags; unsigned long flags;
#ifdef SERIAL_DEBUG_THROTTLE #ifdef SERIAL_DEBUG_THROTTLE
char buf[64]; printk("throttle %s: %d....\n", tty_name(tty),
printk("throttle %s: %d....\n", tty_name(tty, buf),
tty->ldisc.chars_in_buffer(tty)); tty->ldisc.chars_in_buffer(tty));
#endif #endif
@ -991,9 +989,7 @@ static void rs_unthrottle(struct tty_struct * tty)
struct serial_state *info = tty->driver_data; struct serial_state *info = tty->driver_data;
unsigned long flags; unsigned long flags;
#ifdef SERIAL_DEBUG_THROTTLE #ifdef SERIAL_DEBUG_THROTTLE
char buf[64]; printk("unthrottle %s: %d....\n", tty_name(tty),
printk("unthrottle %s: %d....\n", tty_name(tty, buf),
tty->ldisc.chars_in_buffer(tty)); tty->ldisc.chars_in_buffer(tty));
#endif #endif

View File

@ -2861,9 +2861,7 @@ static void cy_throttle(struct tty_struct *tty)
unsigned long flags; unsigned long flags;
#ifdef CY_DEBUG_THROTTLE #ifdef CY_DEBUG_THROTTLE
char buf[64]; printk(KERN_DEBUG "cyc:throttle %s: %ld...ttyC%d\n", tty_name(tty),
printk(KERN_DEBUG "cyc:throttle %s: %ld...ttyC%d\n", tty_name(tty, buf),
tty->ldisc.chars_in_buffer(tty), info->line); tty->ldisc.chars_in_buffer(tty), info->line);
#endif #endif
@ -2902,10 +2900,8 @@ static void cy_unthrottle(struct tty_struct *tty)
unsigned long flags; unsigned long flags;
#ifdef CY_DEBUG_THROTTLE #ifdef CY_DEBUG_THROTTLE
char buf[64];
printk(KERN_DEBUG "cyc:unthrottle %s: %ld...ttyC%d\n", printk(KERN_DEBUG "cyc:unthrottle %s: %ld...ttyC%d\n",
tty_name(tty, buf), tty_chars_in_buffer(tty), info->line); tty_name(tty), tty_chars_in_buffer(tty), info->line);
#endif #endif
if (serial_paranoia_check(info, tty->name, "cy_unthrottle")) if (serial_paranoia_check(info, tty->name, "cy_unthrottle"))

View File

@ -2274,7 +2274,6 @@ static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
const unsigned char *dp; const unsigned char *dp;
char *f; char *f;
int i; int i;
char buf[64];
char flags = TTY_NORMAL; char flags = TTY_NORMAL;
if (debug & 4) if (debug & 4)
@ -2296,7 +2295,7 @@ static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
break; break;
default: default:
WARN_ONCE(1, "%s: unknown flag %d\n", WARN_ONCE(1, "%s: unknown flag %d\n",
tty_name(tty, buf), flags); tty_name(tty), flags);
break; break;
} }
} }

View File

@ -1179,13 +1179,12 @@ static void n_tty_receive_break(struct tty_struct *tty)
static void n_tty_receive_overrun(struct tty_struct *tty) static void n_tty_receive_overrun(struct tty_struct *tty)
{ {
struct n_tty_data *ldata = tty->disc_data; struct n_tty_data *ldata = tty->disc_data;
char buf[64];
ldata->num_overrun++; ldata->num_overrun++;
if (time_after(jiffies, ldata->overrun_time + HZ) || if (time_after(jiffies, ldata->overrun_time + HZ) ||
time_after(ldata->overrun_time, jiffies)) { time_after(ldata->overrun_time, jiffies)) {
printk(KERN_WARNING "%s: %d input overrun(s)\n", printk(KERN_WARNING "%s: %d input overrun(s)\n",
tty_name(tty, buf), tty_name(tty),
ldata->num_overrun); ldata->num_overrun);
ldata->overrun_time = jiffies; ldata->overrun_time = jiffies;
ldata->num_overrun = 0; ldata->num_overrun = 0;
@ -1460,8 +1459,6 @@ static void n_tty_receive_char_closing(struct tty_struct *tty, unsigned char c)
static void static void
n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag) n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag)
{ {
char buf[64];
switch (flag) { switch (flag) {
case TTY_BREAK: case TTY_BREAK:
n_tty_receive_break(tty); n_tty_receive_break(tty);
@ -1475,7 +1472,7 @@ n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag)
break; break;
default: default:
printk(KERN_ERR "%s: unknown flag %d\n", printk(KERN_ERR "%s: unknown flag %d\n",
tty_name(tty, buf), flag); tty_name(tty), flag);
break; break;
} }
} }

View File

@ -3216,9 +3216,7 @@ rs_throttle(struct tty_struct * tty)
{ {
struct e100_serial *info = (struct e100_serial *)tty->driver_data; struct e100_serial *info = (struct e100_serial *)tty->driver_data;
#ifdef SERIAL_DEBUG_THROTTLE #ifdef SERIAL_DEBUG_THROTTLE
char buf[64]; printk("throttle %s: %lu....\n", tty_name(tty),
printk("throttle %s: %lu....\n", tty_name(tty, buf),
(unsigned long)tty->ldisc.chars_in_buffer(tty)); (unsigned long)tty->ldisc.chars_in_buffer(tty));
#endif #endif
DFLOW(DEBUG_LOG(info->line,"rs_throttle %lu\n", tty->ldisc.chars_in_buffer(tty))); DFLOW(DEBUG_LOG(info->line,"rs_throttle %lu\n", tty->ldisc.chars_in_buffer(tty)));
@ -3238,9 +3236,7 @@ rs_unthrottle(struct tty_struct * tty)
{ {
struct e100_serial *info = (struct e100_serial *)tty->driver_data; struct e100_serial *info = (struct e100_serial *)tty->driver_data;
#ifdef SERIAL_DEBUG_THROTTLE #ifdef SERIAL_DEBUG_THROTTLE
char buf[64]; printk("unthrottle %s: %lu....\n", tty_name(tty),
printk("unthrottle %s: %lu....\n", tty_name(tty, buf),
(unsigned long)tty->ldisc.chars_in_buffer(tty)); (unsigned long)tty->ldisc.chars_in_buffer(tty));
#endif #endif
DFLOW(DEBUG_LOG(info->line,"rs_unthrottle ldisc %d\n", tty->ldisc.chars_in_buffer(tty))); DFLOW(DEBUG_LOG(info->line,"rs_unthrottle ldisc %d\n", tty->ldisc.chars_in_buffer(tty)));

View File

@ -894,12 +894,10 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
* need to rate-limit; it's CAP_SYS_ADMIN only. * need to rate-limit; it's CAP_SYS_ADMIN only.
*/ */
if (uport->flags & UPF_SPD_MASK) { if (uport->flags & UPF_SPD_MASK) {
char buf[64];
dev_notice(uport->dev, dev_notice(uport->dev,
"%s sets custom speed on %s. This is deprecated.\n", "%s sets custom speed on %s. This is deprecated.\n",
current->comm, current->comm,
tty_name(port->tty, buf)); tty_name(port->tty));
} }
uart_change_speed(tty, state, NULL); uart_change_speed(tty, state, NULL);
} }

View File

@ -235,7 +235,6 @@ static void tty_del_file(struct file *file)
/** /**
* tty_name - return tty naming * tty_name - return tty naming
* @tty: tty structure * @tty: tty structure
* @buf: unused
* *
* Convert a tty structure into a name. The name reflects the kernel * 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 * naming policy and if udev is in use may not reflect user space
@ -243,7 +242,7 @@ static void tty_del_file(struct file *file)
* Locking: none * Locking: none
*/ */
const char *tty_name(const struct tty_struct *tty, char *buf) const char *tty_name(const struct tty_struct *tty)
{ {
if (!tty) /* Hmm. NULL pointer. That's fun. */ if (!tty) /* Hmm. NULL pointer. That's fun. */
return "NULL tty"; return "NULL tty";
@ -768,8 +767,7 @@ static void do_tty_hangup(struct work_struct *work)
void tty_hangup(struct tty_struct *tty) void tty_hangup(struct tty_struct *tty)
{ {
#ifdef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP
char buf[64]; printk(KERN_DEBUG "%s hangup...\n", tty_name(tty));
printk(KERN_DEBUG "%s hangup...\n", tty_name(tty, buf));
#endif #endif
schedule_work(&tty->hangup_work); schedule_work(&tty->hangup_work);
} }
@ -788,9 +786,7 @@ EXPORT_SYMBOL(tty_hangup);
void tty_vhangup(struct tty_struct *tty) void tty_vhangup(struct tty_struct *tty)
{ {
#ifdef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP
char buf[64]; printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty));
printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf));
#endif #endif
__tty_hangup(tty, 0); __tty_hangup(tty, 0);
} }
@ -829,9 +825,7 @@ void tty_vhangup_self(void)
static void tty_vhangup_session(struct tty_struct *tty) static void tty_vhangup_session(struct tty_struct *tty)
{ {
#ifdef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP
char buf[64]; printk(KERN_DEBUG "%s vhangup session...\n", tty_name(tty));
printk(KERN_DEBUG "%s vhangup session...\n", tty_name(tty, buf));
#endif #endif
__tty_hangup(tty, 1); __tty_hangup(tty, 1);
} }
@ -1767,7 +1761,6 @@ int tty_release(struct inode *inode, struct file *filp)
struct tty_struct *o_tty = NULL; struct tty_struct *o_tty = NULL;
int do_sleep, final; int do_sleep, final;
int idx; int idx;
char buf[64];
long timeout = 0; long timeout = 0;
int once = 1; int once = 1;
@ -1791,7 +1784,7 @@ int tty_release(struct inode *inode, struct file *filp)
#ifdef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP
printk(KERN_DEBUG "%s: %s (tty count=%d)...\n", __func__, printk(KERN_DEBUG "%s: %s (tty count=%d)...\n", __func__,
tty_name(tty, buf), tty->count); tty_name(tty), tty->count);
#endif #endif
if (tty->ops->close) if (tty->ops->close)
@ -1842,7 +1835,7 @@ int tty_release(struct inode *inode, struct file *filp)
if (once) { if (once) {
once = 0; once = 0;
printk(KERN_WARNING "%s: %s: read/write wait queue active!\n", printk(KERN_WARNING "%s: %s: read/write wait queue active!\n",
__func__, tty_name(tty, buf)); __func__, tty_name(tty));
} }
schedule_timeout_killable(timeout); schedule_timeout_killable(timeout);
if (timeout < 120 * HZ) if (timeout < 120 * HZ)
@ -1854,13 +1847,13 @@ int tty_release(struct inode *inode, struct file *filp)
if (o_tty) { if (o_tty) {
if (--o_tty->count < 0) { if (--o_tty->count < 0) {
printk(KERN_WARNING "%s: bad pty slave count (%d) for %s\n", printk(KERN_WARNING "%s: bad pty slave count (%d) for %s\n",
__func__, o_tty->count, tty_name(o_tty, buf)); __func__, o_tty->count, tty_name(o_tty));
o_tty->count = 0; o_tty->count = 0;
} }
} }
if (--tty->count < 0) { if (--tty->count < 0) {
printk(KERN_WARNING "%s: bad tty->count (%d) for %s\n", printk(KERN_WARNING "%s: bad tty->count (%d) for %s\n",
__func__, tty->count, tty_name(tty, buf)); __func__, tty->count, tty_name(tty));
tty->count = 0; tty->count = 0;
} }
@ -1903,7 +1896,7 @@ int tty_release(struct inode *inode, struct file *filp)
return 0; return 0;
#ifdef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP
printk(KERN_DEBUG "%s: %s: final close\n", __func__, tty_name(tty, buf)); printk(KERN_DEBUG "%s: %s: final close\n", __func__, tty_name(tty));
#endif #endif
/* /*
* Ask the line discipline code to release its structures * Ask the line discipline code to release its structures
@ -1914,7 +1907,8 @@ int tty_release(struct inode *inode, struct file *filp)
tty_flush_works(tty); tty_flush_works(tty);
#ifdef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP
printk(KERN_DEBUG "%s: %s: freeing structure...\n", __func__, tty_name(tty, buf)); printk(KERN_DEBUG "%s: %s: freeing structure...\n", __func__,
tty_name(tty));
#endif #endif
/* /*
* The release_tty function takes care of the details of clearing * The release_tty function takes care of the details of clearing

View File

@ -211,9 +211,7 @@ int tty_unthrottle_safe(struct tty_struct *tty)
void tty_wait_until_sent(struct tty_struct *tty, long timeout) void tty_wait_until_sent(struct tty_struct *tty, long timeout)
{ {
#ifdef TTY_DEBUG_WAIT_UNTIL_SENT #ifdef TTY_DEBUG_WAIT_UNTIL_SENT
char buf[64]; printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty));
printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty, buf));
#endif #endif
if (!timeout) if (!timeout)
timeout = MAX_SCHEDULE_TIMEOUT; timeout = MAX_SCHEDULE_TIMEOUT;

View File

@ -22,9 +22,8 @@
#undef LDISC_DEBUG_HANGUP #undef LDISC_DEBUG_HANGUP
#ifdef LDISC_DEBUG_HANGUP #ifdef LDISC_DEBUG_HANGUP
#define tty_ldisc_debug(tty, f, args...) ({ \ #define tty_ldisc_debug(tty, f, args...) ({ \
char __b[64]; \ printk(KERN_DEBUG "%s: %s: " f, __func__, tty_name(tty), ##args); \
printk(KERN_DEBUG "%s: %s: " f, __func__, tty_name(tty, __b), ##args); \
}) })
#else #else
#define tty_ldisc_debug(tty, f, args...) #define tty_ldisc_debug(tty, f, args...)
@ -483,7 +482,6 @@ static void tty_ldisc_close(struct tty_struct *tty, struct tty_ldisc *ld)
static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old) static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old)
{ {
char buf[64];
struct tty_ldisc *new_ldisc; struct tty_ldisc *new_ldisc;
int r; int r;
@ -504,7 +502,7 @@ static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old)
if (r < 0) if (r < 0)
panic("Couldn't open N_TTY ldisc for " panic("Couldn't open N_TTY ldisc for "
"%s --- error %d.", "%s --- error %d.",
tty_name(tty, buf), r); tty_name(tty), r);
} }
} }

View File

@ -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, extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
const char *routine); const char *routine);
extern const char *tty_name(const struct tty_struct *tty, char *buf); extern const char *tty_name(const struct tty_struct *tty);
extern void tty_wait_until_sent(struct tty_struct *tty, long timeout); extern void tty_wait_until_sent(struct tty_struct *tty, long timeout);
extern int tty_check_change(struct tty_struct *tty); extern int tty_check_change(struct tty_struct *tty);
extern void __stop_tty(struct tty_struct *tty); extern void __stop_tty(struct tty_struct *tty);