提交 a17e74c5 编写于 作者: A Andy Shevchenko 提交者: Greg Kroah-Hartman

serial: core: enforce type for upf_t when copying

upf_t is a bitwise defined type and any assignment from different, but
compatible, types makes static analyzer unhappy.

drivers/tty/serial/serial_core.c:793:29: warning: incorrect type in assignment (different base types)
drivers/tty/serial/serial_core.c:793:29:    expected int [signed] flags
drivers/tty/serial/serial_core.c:793:29:    got restricted upf_t [usertype] flags
drivers/tty/serial/serial_core.c:867:19: warning: incorrect type in assignment (different base types)
drivers/tty/serial/serial_core.c:867:19:    expected restricted upf_t [usertype] new_flags
drivers/tty/serial/serial_core.c:867:19:    got int [signed] flags

Enforce corresponding types when upf_t being assigned.

Note, we need __force attribute due to the scope of variable. It's being
used in user space with plain old type while kernel uses bitwise one.
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 bdc4704b
...@@ -744,7 +744,7 @@ static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo) ...@@ -744,7 +744,7 @@ static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo)
if (HIGH_BITS_OFFSET) if (HIGH_BITS_OFFSET)
retinfo->port_high = (long) uport->iobase >> HIGH_BITS_OFFSET; retinfo->port_high = (long) uport->iobase >> HIGH_BITS_OFFSET;
retinfo->irq = uport->irq; retinfo->irq = uport->irq;
retinfo->flags = uport->flags; retinfo->flags = (__force int)uport->flags;
retinfo->xmit_fifo_size = uport->fifosize; retinfo->xmit_fifo_size = uport->fifosize;
retinfo->baud_base = uport->uartclk / 16; retinfo->baud_base = uport->uartclk / 16;
retinfo->close_delay = jiffies_to_msecs(port->close_delay) / 10; retinfo->close_delay = jiffies_to_msecs(port->close_delay) / 10;
...@@ -818,7 +818,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, ...@@ -818,7 +818,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
new_info->type != uport->type); new_info->type != uport->type);
old_flags = uport->flags; old_flags = uport->flags;
new_flags = new_info->flags; new_flags = (__force upf_t)new_info->flags;
old_custom_divisor = uport->custom_divisor; old_custom_divisor = uport->custom_divisor;
if (!capable(CAP_SYS_ADMIN)) { if (!capable(CAP_SYS_ADMIN)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册