Skip to contentSkip to conversation

staging: comedi: usbdux: remove redundant initialization of val

PATCH In review Colin King 2 participants 2 messages Nov 7, 2017 – Nov 8, 2017

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 staging: comedi: usbdux: remove redundant initialization of val

From: Colin Ian King <[email protected]>

The early initialization of val is redundant as the value is never read and is updated inside a for-loop. Remove the initialization and move the declaration and initialization to the for-loop scope. Cleans up clang warning:

drivers/staging/comedi/drivers/usbdux.c:812:15: warning: Value stored to 'val' during its initialization is never read

---
 drivers/staging/comedi/drivers/usbdux.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/comedi/drivers/usbdux.c +1 -2
index f4f05d29d30d..ede064b47aac 100644
@@ -809,7 +809,6 @@ static int usbdux_ao_insn_write(struct comedi_device *dev,
 {
 	struct usbdux_private *devpriv = dev->private;
 	unsigned int chan = CR_CHAN(insn->chanspec);
-	unsigned int val = s->readback[chan];
 	__le16 *p = (__le16 *)&devpriv->dux_commands[2];
 	int ret = -EBUSY;
 	int i;
@@ -825,7 +824,7 @@ static int usbdux_ao_insn_write(struct comedi_device *dev,
 	devpriv->dux_commands[4] = chan << 6;
 
 	for (i = 0; i < insn->n; i++) {
-		val = data[i];
+		unsigned int val = data[i];
 
 		/* one 16 bit value */
 		*p = cpu_to_le16(val);
Signature · 1 line
2.14.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Colin King

From: Colin Ian King <[email protected]>

The early initialization of val is redundant as the value is never read and is updated inside a for-loop. Remove the initialization and move the declaration and initialization to the for-loop scope. Cleans up clang warning:

drivers/staging/comedi/drivers/usbdux.c:812:15: warning: Value stored to 'val' during its initialization is never read

---
  drivers/staging/comedi/drivers/usbdux.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/comedi/drivers/usbdux.c +0 -1
index f4f05d29d30d..ede064b47aac 100644
@@ -809,7 +809,6 @@ static int usbdux_ao_insn_write(struct comedi_device *dev,
  {
  	struct usbdux_private *devpriv = dev->private;
  	unsigned int chan = CR_CHAN(insn->chanspec);
-	unsigned int val = s->readback[chan];
  	__le16 *p = (__le16 *)&devpriv->dux_commands[2];
  	int ret = -EBUSY;
  	int i;

drivers/staging/comedi/drivers/usbdux.c static int usbdux_ao_insn_write(struct comedi_device *dev, · line 830

Quoted 8 lines
drivers/staging/comedi/drivers/usbdux.c +1 -1
@@ -825,7 +824,7 @@ static int usbdux_ao_insn_write(struct comedi_device *dev,
  	devpriv->dux_commands[4] = chan << 6;
 
  	for (i = 0; i < insn->n; i++) {
-		val = data[i];
+		unsigned int val = data[i];
 
  		/* one 16 bit value */
  		*p = cpu_to_le16(val);

Thanks for catching that. It looks like it has been redundant since commit 65a847477f63 ("staging: comedi: usbdux: use comedi_subdevice 'readback'").

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]> )=-
-=(                          Web: http://www.mev.co.uk/  )=-