2021-04-26 10:13:16

by Colin King

[permalink] [raw]
Subject: [PATCH] serial: meson: remove redundant initialization of variable id

From: Colin Ian King <[email protected]>

The variable id being initialized with a value that is never read
and it is being updated later with a new value. The initialization is
redundant and can be removed. Since id is just being used in a for-loop
inside a local scope, move the declaration of id to that scope.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <[email protected]>
---
drivers/tty/serial/meson_uart.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index 529cd0289056..d7f55031b2cf 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -716,12 +716,13 @@ static int meson_uart_probe(struct platform_device *pdev)
struct resource *res_mem, *res_irq;
struct uart_port *port;
int ret = 0;
- int id = -1;

if (pdev->dev.of_node)
pdev->id = of_alias_get_id(pdev->dev.of_node, "serial");

if (pdev->id < 0) {
+ int id;
+
for (id = AML_UART_PORT_OFFSET; id < AML_UART_PORT_NUM; id++) {
if (!meson_ports[id]) {
pdev->id = id;
--
2.30.2


2021-04-26 15:19:48

by Kevin Hilman

[permalink] [raw]
Subject: Re: [PATCH] serial: meson: remove redundant initialization of variable id

Colin King <[email protected]> writes:

> From: Colin Ian King <[email protected]>
>
> The variable id being initialized with a value that is never read
> and it is being updated later with a new value. The initialization is
> redundant and can be removed. Since id is just being used in a for-loop
> inside a local scope, move the declaration of id to that scope.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <[email protected]>

Reviewed-by: Kevin Hilman <[email protected]>

> ---
> drivers/tty/serial/meson_uart.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
> index 529cd0289056..d7f55031b2cf 100644
> --- a/drivers/tty/serial/meson_uart.c
> +++ b/drivers/tty/serial/meson_uart.c
> @@ -716,12 +716,13 @@ static int meson_uart_probe(struct platform_device *pdev)
> struct resource *res_mem, *res_irq;
> struct uart_port *port;
> int ret = 0;
> - int id = -1;
>
> if (pdev->dev.of_node)
> pdev->id = of_alias_get_id(pdev->dev.of_node, "serial");
>
> if (pdev->id < 0) {
> + int id;
> +
> for (id = AML_UART_PORT_OFFSET; id < AML_UART_PORT_NUM; id++) {
> if (!meson_ports[id]) {
> pdev->id = id;
> --
> 2.30.2

2021-04-27 18:33:10

by Martin Blumenstingl

[permalink] [raw]
Subject: Re: [PATCH] serial: meson: remove redundant initialization of variable id

On Mon, Apr 26, 2021 at 12:11 PM Colin King <[email protected]> wrote:
>
> From: Colin Ian King <[email protected]>
>
> The variable id being initialized with a value that is never read
> and it is being updated later with a new value. The initialization is
> redundant and can be removed. Since id is just being used in a for-loop
> inside a local scope, move the declaration of id to that scope.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <[email protected]>
Reviewed-by: Martin Blumenstingl <[email protected]>