serial: core: don't use snprintf() for formatting sysfs attrs
As per the documentation (Documentation/filesystems/sysfs.rst), snprintf() should not be used for formatting values returned by sysfs. For all of the instances in serial_core.c, we know that the string will be <PAGE_SIZE in length, so just use sprintf(). Issue identified by Coccinelle. Signed-off-by: Alex Dewar <alex.dewar90@gmail.com> Link: https://lore.kernel.org/r/20200824223932.27709-1-alex.dewar90@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c9fe14ac8b
commit
9cfbf7a641
|
@ -2637,7 +2637,7 @@ static ssize_t uartclk_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", tmp.baud_base * 16);
|
||||
return sprintf(buf, "%d\n", tmp.baud_base * 16);
|
||||
}
|
||||
|
||||
static ssize_t type_show(struct device *dev,
|
||||
|
@ -2647,7 +2647,7 @@ static ssize_t type_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", tmp.type);
|
||||
return sprintf(buf, "%d\n", tmp.type);
|
||||
}
|
||||
|
||||
static ssize_t line_show(struct device *dev,
|
||||
|
@ -2657,7 +2657,7 @@ static ssize_t line_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", tmp.line);
|
||||
return sprintf(buf, "%d\n", tmp.line);
|
||||
}
|
||||
|
||||
static ssize_t port_show(struct device *dev,
|
||||
|
@ -2671,7 +2671,7 @@ static ssize_t port_show(struct device *dev,
|
|||
ioaddr = tmp.port;
|
||||
if (HIGH_BITS_OFFSET)
|
||||
ioaddr |= (unsigned long)tmp.port_high << HIGH_BITS_OFFSET;
|
||||
return snprintf(buf, PAGE_SIZE, "0x%lX\n", ioaddr);
|
||||
return sprintf(buf, "0x%lX\n", ioaddr);
|
||||
}
|
||||
|
||||
static ssize_t irq_show(struct device *dev,
|
||||
|
@ -2681,7 +2681,7 @@ static ssize_t irq_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", tmp.irq);
|
||||
return sprintf(buf, "%d\n", tmp.irq);
|
||||
}
|
||||
|
||||
static ssize_t flags_show(struct device *dev,
|
||||
|
@ -2691,7 +2691,7 @@ static ssize_t flags_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "0x%X\n", tmp.flags);
|
||||
return sprintf(buf, "0x%X\n", tmp.flags);
|
||||
}
|
||||
|
||||
static ssize_t xmit_fifo_size_show(struct device *dev,
|
||||
|
@ -2701,7 +2701,7 @@ static ssize_t xmit_fifo_size_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", tmp.xmit_fifo_size);
|
||||
return sprintf(buf, "%d\n", tmp.xmit_fifo_size);
|
||||
}
|
||||
|
||||
static ssize_t close_delay_show(struct device *dev,
|
||||
|
@ -2711,7 +2711,7 @@ static ssize_t close_delay_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", tmp.close_delay);
|
||||
return sprintf(buf, "%d\n", tmp.close_delay);
|
||||
}
|
||||
|
||||
static ssize_t closing_wait_show(struct device *dev,
|
||||
|
@ -2721,7 +2721,7 @@ static ssize_t closing_wait_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", tmp.closing_wait);
|
||||
return sprintf(buf, "%d\n", tmp.closing_wait);
|
||||
}
|
||||
|
||||
static ssize_t custom_divisor_show(struct device *dev,
|
||||
|
@ -2731,7 +2731,7 @@ static ssize_t custom_divisor_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", tmp.custom_divisor);
|
||||
return sprintf(buf, "%d\n", tmp.custom_divisor);
|
||||
}
|
||||
|
||||
static ssize_t io_type_show(struct device *dev,
|
||||
|
@ -2741,7 +2741,7 @@ static ssize_t io_type_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", tmp.io_type);
|
||||
return sprintf(buf, "%d\n", tmp.io_type);
|
||||
}
|
||||
|
||||
static ssize_t iomem_base_show(struct device *dev,
|
||||
|
@ -2751,7 +2751,7 @@ static ssize_t iomem_base_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "0x%lX\n", (unsigned long)tmp.iomem_base);
|
||||
return sprintf(buf, "0x%lX\n", (unsigned long)tmp.iomem_base);
|
||||
}
|
||||
|
||||
static ssize_t iomem_reg_shift_show(struct device *dev,
|
||||
|
@ -2761,7 +2761,7 @@ static ssize_t iomem_reg_shift_show(struct device *dev,
|
|||
struct tty_port *port = dev_get_drvdata(dev);
|
||||
|
||||
uart_get_info(port, &tmp);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", tmp.iomem_reg_shift);
|
||||
return sprintf(buf, "%d\n", tmp.iomem_reg_shift);
|
||||
}
|
||||
|
||||
static ssize_t console_show(struct device *dev,
|
||||
|
|
Loading…
Reference in New Issue