tty: remove buf parameter from tty_name()
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Tue, 31 Mar 2015 13:55:59 +0000 (15:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 May 2015 20:26:57 +0000 (22:26 +0200)
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>
drivers/input/serio/serport.c
drivers/tty/amiserial.c
drivers/tty/cyclades.c
drivers/tty/n_gsm.c
drivers/tty/n_tty.c
drivers/tty/serial/crisv10.c
drivers/tty/serial/serial_core.c
drivers/tty/tty_io.c
drivers/tty/tty_ioctl.c
drivers/tty/tty_ldisc.c
include/linux/tty.h

index 69175b8253468cf5d2319659b1496e3ac32d5b10..9c927d35c1f5d71c4822e4f9e5310ce8a6562876 100644 (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 serio *serio;
-       char name[64];
 
        if (test_and_set_bit(SERPORT_BUSY, &serport->flags))
                return -EBUSY;
@@ -177,7 +176,7 @@ static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, u
                return -ENOMEM;
 
        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.type = SERIO_RS232;
        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_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));
        serio_unregister_port(serport->serio);
index b2d76005595225ebd9f1412bf250ad768132d660..894d3a84e285ce90ed219ca711da7d48d3eefaab 100644 (file)
@@ -966,9 +966,7 @@ static void rs_throttle(struct tty_struct * tty)
        struct serial_state *info = tty->driver_data;
        unsigned long flags;
 #ifdef SERIAL_DEBUG_THROTTLE
-       char    buf[64];
-
-       printk("throttle %s: %d....\n", tty_name(tty, buf),
+       printk("throttle %s: %d....\n", tty_name(tty),
               tty->ldisc.chars_in_buffer(tty));
 #endif
 
@@ -991,9 +989,7 @@ static void rs_unthrottle(struct tty_struct * tty)
        struct serial_state *info = tty->driver_data;
        unsigned long flags;
 #ifdef SERIAL_DEBUG_THROTTLE
-       char    buf[64];
-
-       printk("unthrottle %s: %d....\n", tty_name(tty, buf),
+       printk("unthrottle %s: %d....\n", tty_name(tty),
               tty->ldisc.chars_in_buffer(tty));
 #endif
 
index fd66f57390d048a049568d465f818d76847214d0..87f6578c6f4a389fbad842aebe9077d1577bab3a 100644 (file)
@@ -2861,9 +2861,7 @@ static void cy_throttle(struct tty_struct *tty)
        unsigned long flags;
 
 #ifdef CY_DEBUG_THROTTLE
-       char buf[64];
-
-       printk(KERN_DEBUG "cyc:throttle %s: %ld...ttyC%d\n", tty_name(tty, buf),
+       printk(KERN_DEBUG "cyc:throttle %s: %ld...ttyC%d\n", tty_name(tty),
                        tty->ldisc.chars_in_buffer(tty), info->line);
 #endif
 
@@ -2902,10 +2900,8 @@ static void cy_unthrottle(struct tty_struct *tty)
        unsigned long flags;
 
 #ifdef CY_DEBUG_THROTTLE
-       char buf[64];
-
        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
 
        if (serial_paranoia_check(info, tty->name, "cy_unthrottle"))
index 91abc00aa833b8493fe721e05024cd8368e23aa6..7e039669fc82747cb3303f43658dfc396d93b665 100644 (file)
@@ -2274,7 +2274,6 @@ static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
        const unsigned char *dp;
        char *f;
        int i;
-       char buf[64];
        char flags = TTY_NORMAL;
 
        if (debug & 4)
@@ -2296,7 +2295,7 @@ static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
                        break;
                default:
                        WARN_ONCE(1, "%s: unknown flag %d\n",
-                              tty_name(tty, buf), flags);
+                              tty_name(tty), flags);
                        break;
                }
        }
index cf6e0f2e1331fd46310a6834d99896e2b943ea19..54da8f49394d866589f91756010b878ed20e97a4 100644 (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)
 {
        struct n_tty_data *ldata = tty->disc_data;
-       char buf[64];
 
        ldata->num_overrun++;
        if (time_after(jiffies, ldata->overrun_time + HZ) ||
                        time_after(ldata->overrun_time, jiffies)) {
                printk(KERN_WARNING "%s: %d input overrun(s)\n",
-                       tty_name(tty, buf),
+                       tty_name(tty),
                        ldata->num_overrun);
                ldata->overrun_time = jiffies;
                ldata->num_overrun = 0;
@@ -1460,8 +1459,6 @@ static void n_tty_receive_char_closing(struct tty_struct *tty, unsigned char c)
 static void
 n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag)
 {
-       char buf[64];
-
        switch (flag) {
        case TTY_BREAK:
                n_tty_receive_break(tty);
@@ -1475,7 +1472,7 @@ n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag)
                break;
        default:
                printk(KERN_ERR "%s: unknown flag %d\n",
-                      tty_name(tty, buf), flag);
+                      tty_name(tty), flag);
                break;
        }
 }
index 0c1825b0b41d00de927e19fc332e03db014e84a9..568ea0d2d6997ddde0198a15f9952f8f943f6c61 100644 (file)
@@ -3216,9 +3216,7 @@ rs_throttle(struct tty_struct * tty)
 {
        struct e100_serial *info = (struct e100_serial *)tty->driver_data;
 #ifdef SERIAL_DEBUG_THROTTLE
-       char    buf[64];
-
-       printk("throttle %s: %lu....\n", tty_name(tty, buf),
+       printk("throttle %s: %lu....\n", tty_name(tty),
               (unsigned long)tty->ldisc.chars_in_buffer(tty));
 #endif
        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;
 #ifdef SERIAL_DEBUG_THROTTLE
-       char    buf[64];
-
-       printk("unthrottle %s: %lu....\n", tty_name(tty, buf),
+       printk("unthrottle %s: %lu....\n", tty_name(tty),
               (unsigned long)tty->ldisc.chars_in_buffer(tty));
 #endif
        DFLOW(DEBUG_LOG(info->line,"rs_unthrottle ldisc %d\n", tty->ldisc.chars_in_buffer(tty)));
index 0b7bb12dfc68bc7edc45f7274a4e75acb9238a59..eec067d8eedb96048ce5db901c863bfb3ac8fbb0 100644 (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.
                         */
                        if (uport->flags & UPF_SPD_MASK) {
-                               char buf[64];
-
                                dev_notice(uport->dev,
                                       "%s sets custom speed on %s. This is deprecated.\n",
                                      current->comm,
-                                     tty_name(port->tty, buf));
+                                     tty_name(port->tty));
                        }
                        uart_change_speed(tty, state, NULL);
                }
index 1eaf0fbd99e45e0e1df8a198284347ec818ce5df..57fc6ee12332e6932472ac1cc1796d607f114e4f 100644 (file)
@@ -235,7 +235,6 @@ static void tty_del_file(struct file *file)
 /**
  *     tty_name        -       return tty naming
  *     @tty: tty structure
- *     @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
@@ -243,7 +242,7 @@ static void tty_del_file(struct file *file)
  *     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. */
                return "NULL tty";
@@ -768,8 +767,7 @@ static void do_tty_hangup(struct work_struct *work)
 void tty_hangup(struct tty_struct *tty)
 {
 #ifdef TTY_DEBUG_HANGUP
-       char    buf[64];
-       printk(KERN_DEBUG "%s hangup...\n", tty_name(tty, buf));
+       printk(KERN_DEBUG "%s hangup...\n", tty_name(tty));
 #endif
        schedule_work(&tty->hangup_work);
 }
@@ -788,9 +786,7 @@ EXPORT_SYMBOL(tty_hangup);
 void tty_vhangup(struct tty_struct *tty)
 {
 #ifdef TTY_DEBUG_HANGUP
-       char    buf[64];
-
-       printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf));
+       printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty));
 #endif
        __tty_hangup(tty, 0);
 }
@@ -829,9 +825,7 @@ void tty_vhangup_self(void)
 static void tty_vhangup_session(struct tty_struct *tty)
 {
 #ifdef TTY_DEBUG_HANGUP
-       char    buf[64];
-
-       printk(KERN_DEBUG "%s vhangup session...\n", tty_name(tty, buf));
+       printk(KERN_DEBUG "%s vhangup session...\n", tty_name(tty));
 #endif
        __tty_hangup(tty, 1);
 }
@@ -1767,7 +1761,6 @@ int tty_release(struct inode *inode, struct file *filp)
        struct tty_struct *o_tty = NULL;
        int     do_sleep, final;
        int     idx;
-       char    buf[64];
        long    timeout = 0;
        int     once = 1;
 
@@ -1791,7 +1784,7 @@ int tty_release(struct inode *inode, struct file *filp)
 
 #ifdef TTY_DEBUG_HANGUP
        printk(KERN_DEBUG "%s: %s (tty count=%d)...\n", __func__,
-                       tty_name(tty, buf), tty->count);
+                       tty_name(tty), tty->count);
 #endif
 
        if (tty->ops->close)
@@ -1842,7 +1835,7 @@ int tty_release(struct inode *inode, struct file *filp)
                if (once) {
                        once = 0;
                        printk(KERN_WARNING "%s: %s: read/write wait queue active!\n",
-                              __func__, tty_name(tty, buf));
+                              __func__, tty_name(tty));
                }
                schedule_timeout_killable(timeout);
                if (timeout < 120 * HZ)
@@ -1854,13 +1847,13 @@ int tty_release(struct inode *inode, struct file *filp)
        if (o_tty) {
                if (--o_tty->count < 0) {
                        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;
                }
        }
        if (--tty->count < 0) {
                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;
        }
 
@@ -1903,7 +1896,7 @@ int tty_release(struct inode *inode, struct file *filp)
                return 0;
 
 #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
        /*
         * 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);
 
 #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
        /*
         * The release_tty function takes care of the details of clearing
index 8e53fe4696647e6bbfd8951e3a96a0d070ce28af..5232fb60b0b16b9a235ee6cc090104380899b173 100644 (file)
@@ -211,9 +211,7 @@ int tty_unthrottle_safe(struct tty_struct *tty)
 void tty_wait_until_sent(struct tty_struct *tty, long timeout)
 {
 #ifdef TTY_DEBUG_WAIT_UNTIL_SENT
-       char buf[64];
-
-       printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty, buf));
+       printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty));
 #endif
        if (!timeout)
                timeout = MAX_SCHEDULE_TIMEOUT;
index 3737f55272d2c1184463edc3714f89fb2724730e..c07fb5d9bcf9b5429689a908417021fb5716e8f9 100644 (file)
@@ -22,9 +22,8 @@
 #undef LDISC_DEBUG_HANGUP
 
 #ifdef LDISC_DEBUG_HANGUP
-#define tty_ldisc_debug(tty, f, args...) ({                                   \
-       char __b[64];                                                          \
-       printk(KERN_DEBUG "%s: %s: " f, __func__, tty_name(tty, __b), ##args); \
+#define tty_ldisc_debug(tty, f, args...) ({                              \
+       printk(KERN_DEBUG "%s: %s: " f, __func__, tty_name(tty), ##args); \
 })
 #else
 #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)
 {
-       char buf[64];
        struct tty_ldisc *new_ldisc;
        int r;
 
@@ -504,7 +502,7 @@ static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old)
                if (r < 0)
                        panic("Couldn't open N_TTY ldisc for "
                              "%s --- error %d.",
-                             tty_name(tty, buf), r);
+                             tty_name(tty), r);
        }
 }
 
index 4cbecfc7b3c978eec97c2fe92ec463cd6237cbea..9a72c9144d8a64989235e19e7843aa48fbbcad05 100644 (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,
                              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 int tty_check_change(struct tty_struct *tty);
 extern void __stop_tty(struct tty_struct *tty);