staging: comedi: dt2801: fix using uninitialized variable warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As pointed out by Fengguang Wu, the calls to dt2801_readdata() return the
data read thru a pointer (the address of a local variable) passed as a
parameter. If this local variable is not initialized it produces a warning
during the build of the form:

drivers/staging/comedi/drivers/dt2801.c: In function 'dt2801_ai_insn_read':
drivers/staging/comedi/drivers/dt2801.c:273:14: warning: 'hb' is used
      uninitialized in this function [-Wuninitialized]

Fix these warning by making sure the local variables are initialized.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Reported-by: Fengguang Wu <fengguang.wu@xxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/dt2801.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c
index 1a2b0e4..811c8c5 100644
--- a/drivers/staging/comedi/drivers/dt2801.c
+++ b/drivers/staging/comedi/drivers/dt2801.c
@@ -260,7 +260,8 @@ static int dt2801_readdata(struct comedi_device *dev, int *data)
 
 static int dt2801_readdata2(struct comedi_device *dev, int *data)
 {
-	int lb, hb;
+	int lb = 0;
+	int hb = 0;
 	int ret;
 
 	ret = dt2801_readdata(dev, &lb);
@@ -532,7 +533,7 @@ static int dt2801_dio_insn_bits(struct comedi_device *dev,
 				unsigned int *data)
 {
 	int which = (s == &dev->subdevices[3]) ? 1 : 0;
-	unsigned int val;
+	unsigned int val = 0;
 
 	if (comedi_dio_update_state(s, data)) {
 		dt2801_writecmd(dev, DT_C_WRITE_DIG);
-- 
1.8.3.2

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux