Skip to contentSkip to conversation

USB: serial: iuu_phoenix: remove redundant variable 'error'

PATCH In review Colin King 2 participants 2 messages Mar 27, 2021 – Apr 1, 2021

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 USB: serial: iuu_phoenix: remove redundant variable 'error'

From: Colin Ian King <[email protected]>

The variable error is initialized to 0 and is set to 1 this value is never read as it is on an immediate return path. The only read of error is to check it is 0 and this check is always true at that point of the code. The variable is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/usb/serial/iuu_phoenix.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/serial/iuu_phoenix.c +1 -3
index 093afd67a664..19753611e7b0 100644
@@ -643,7 +643,6 @@ static void iuu_uart_read_callback(struct urb *urb)
 	struct iuu_private *priv = usb_get_serial_port_data(port);
 	unsigned long flags;
 	int status = urb->status;
-	int error = 0;
 	int len = 0;
 	unsigned char *data = urb->transfer_buffer;
 	priv->poll++;
@@ -660,12 +659,11 @@ static void iuu_uart_read_callback(struct urb *urb)
 	if (urb->actual_length > 1) {
 		dev_dbg(&port->dev, "%s - urb->actual_length = %i\n", __func__,
 		    urb->actual_length);
-		error = 1;
 		return;
 	}
 	/* if len > 0 call readbuf */
 
-	if (len > 0 && error == 0) {
+	if (len > 0) {
 		dev_dbg(&port->dev, "%s - call read buf - len to read is %i\n",
 			__func__, len);
 		status = iuu_read_buf(port, len);
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 27 lines · Colin King

From: Colin Ian King <[email protected]>

The variable error is initialized to 0 and is set to 1 this value is never read as it is on an immediate return path. The only read of error is to check it is 0 and this check is always true at that point of the code. The variable is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/usb/serial/iuu_phoenix.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/serial/iuu_phoenix.c +0 -1
index 093afd67a664..19753611e7b0 100644
@@ -643,7 +643,6 @@ static void iuu_uart_read_callback(struct urb *urb)
 	struct iuu_private *priv = usb_get_serial_port_data(port);
 	unsigned long flags;
 	int status = urb->status;
-	int error = 0;
 	int len = 0;
 	unsigned char *data = urb->transfer_buffer;
 	priv->poll++;

drivers/usb/serial/iuu_phoenix.c static void iuu_uart_read_callback(struct urb *urb) · line 662

Quoted 5 lines
drivers/usb/serial/iuu_phoenix.c +0 -1
@@ -660,12 +659,11 @@ static void iuu_uart_read_callback(struct urb *urb)
 	if (urb->actual_length > 1) {
 		dev_dbg(&port->dev, "%s - urb->actual_length = %i\n", __func__,
 		    urb->actual_length);
-		error = 1;
 		return;

Heh, I guess the author at some point intended not return here, but who knows. The rest of this function is about as esoteric.

drivers/usb/serial/iuu_phoenix.c static void iuu_uart_read_callback(struct urb *urb) · line 669

Quoted 8 lines
drivers/usb/serial/iuu_phoenix.c +1 -1
 	}
 	/* if len > 0 call readbuf */
 
-	if (len > 0 && error == 0) {
+	if (len > 0) {
 		dev_dbg(&port->dev, "%s - call read buf - len to read is %i\n",
 			__func__, len);
 		status = iuu_read_buf(port, len);

Now applied, thanks.

Johan