Skip to contentSkip to conversation

iio: accel: fxls8962af: Initialize return value

PATCH In review Souptick Joarder 4 participants 6 messages Jul 9, 2021 – Jul 10, 2021 1 message not in the archive IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: accel: fxls8962af: Initialize return value

kernel test robot throws below warning ->

smatch warnings:
drivers/iio/accel/fxls8962af-core.c:640 fxls8962af_i2c_raw_read_errata3() error: uninitialized symbol 'ret'.

Initialize it.

---
 drivers/iio/accel/fxls8962af-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/fxls8962af-core.c +1 -1
index 078d87865fde..8af1c8f58e83 100644
@@ -628,7 +628,7 @@ static int fxls8962af_i2c_raw_read_errata3(struct fxls8962af_data *data,
 					   u16 *buffer, int samples,
 					   int sample_length)
 {
-	int i, ret;
+	int i, ret = -EINVAL;
 
 	for (i = 0; i < samples; i++) {
 		ret = regmap_raw_read(data->regmap, FXLS8962AF_BUF_X_LSB,
Signature · 1 line
2.25.1
#1 lore raw

Hi Souptick,

Quoted 21 lines · Souptick Joarder

kernel test robot throws below warning ->

smatch warnings:
drivers/iio/accel/fxls8962af-core.c:640 fxls8962af_i2c_raw_read_errata3() error: uninitialized symbol 'ret'.

Initialize it.

---
 drivers/iio/accel/fxls8962af-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/fxls8962af-core.c +0 -0
index 078d87865fde..8af1c8f58e83 100644

drivers/iio/accel/fxls8962af-core.c static int fxls8962af_i2c_raw_read_errata3(struct fxls8962af_data *data, · line 634

Quoted 8 lines
drivers/iio/accel/fxls8962af-core.c +1 -1
@@ -628,7 +628,7 @@ static int fxls8962af_i2c_raw_read_errata3(struct fxls8962af_data *data,
                                           u16 *buffer, int samples,
                                           int sample_length)
 {
-       int i, ret;
+       int i, ret = -EINVAL;
 
        for (i = 0; i < samples; i++) {
                ret = regmap_raw_read(data->regmap, FXLS8962AF_BUF_X_LSB,

Would the change below work?

drivers/iio/accel/fxls8962af-core.c +0 -0
@@ -637,7 +637,7 @@ static int fxls8962af_i2c_raw_read_errata3(struct

fxls8962af_data *data,

                        return ret;
        }

- return ret;
+ return 0;
}

#2 lore raw

Hi Souptick and Fabio.

Quoted 15 lines · Fabio Estevam

Hi Souptick,

Quoted 12 lines · Souptick Joarder

kernel test robot throws below warning ->

smatch warnings:
drivers/iio/accel/fxls8962af-core.c:640 fxls8962af_i2c_raw_read_errata3() error: uninitialized symbol 'ret'.

Initialize it.

Missing fixes-tag ;)

[ ... ]

drivers/iio/accel/fxls8962af-core.c static int fxls8962af_i2c_raw_read_errata3(struct · line 642

Quoted 13 lines

Would the change below work?

drivers/iio/accel/fxls8962af-core.c +1 -1
@@ -637,7 +637,7 @@ static int fxls8962af_i2c_raw_read_errata3(struct
 fxls8962af_data *data,
                        return ret;
        }
 
-       return ret;
+       return 0;
 }

I have already submitted a patch for this :)
https://patchwork.kernel.org/project/linux-iio/patch/[email protected]/

/Sean

#5 lore raw
In reply to a message not in the archive
Quoted 35 lines · Souptick Joarder
Quoted 33 lines · Fabio Estevam,

Hi Souptick,

Quoted 9 lines · Souptick Joarder

kernel test robot throws below warning ->

smatch warnings:
drivers/iio/accel/fxls8962af-core.c:640 fxls8962af_i2c_raw_read_errata3() error: uninitialized symbol 'ret'.

Initialize it.

Review

Quoted 8 lines
---
 drivers/iio/accel/fxls8962af-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/iio/accel/fxls8962af-core.c

drivers/iio/accel/fxls8962af-core.c static int fxls8962af_i2c_raw_read_errata3(struct

Quoted 4 lines

index 078d87865fde..8af1c8f58e83 100644

drivers/iio/accel/fxls8962af-core.c +0 -0
@@ -628,7 +628,7 @@ static int fxls8962af_i2c_raw_read_errata3(struct

fxls8962af_data *data,

Quoted 6 lines
drivers/iio/accel/fxls8962af-core.c +1 -1
                                           u16 *buffer, int samples,
                                           int sample_length)
 {
-       int i, ret;
+       int i, ret = -EINVAL;
 
Quoted 8 lines
Quoted 5 lines

drivers/iio/accel/fxls8962af-core.c static int fxls8962af_i2c_raw_read_errata3(struct · line 634

Quoted 2 lines
drivers/iio/accel/fxls8962af-core.c +0 -0
        for (i = 0; i < samples; i++) {
                ret = regmap_raw_read(data->regmap, FXLS8962AF_BUF_X_LSB,

Would the change below work?

This function returns -ERRNO when failed. If it is not entering loop, ideally it should return -ERRNO, not 0. No ?

samples can't be 0, as fxls8962af_fifo_transfer() is never called if samples are 0 :)

Quoted 13 lines
Quoted 13 lines
drivers/iio/accel/fxls8962af-core.c +1 -1
@@ -637,7 +637,7 @@ static int fxls8962af_i2c_raw_read_errata3(struct
 fxls8962af_data *data,
                        return ret;
        }
 
-       return ret;
+       return 0;
 }
 
#6 lore raw
Quoted 39 lines · Sean Nyekjaer
Quoted 38 lines · Souptick Joarder
Quoted 36 lines · Fabio Estevam,

Hi Souptick,

Quoted 9 lines · Souptick Joarder

kernel test robot throws below warning ->

smatch warnings:
drivers/iio/accel/fxls8962af-core.c:640 fxls8962af_i2c_raw_read_errata3() error: uninitialized symbol 'ret'.

Initialize it.

Review

Quoted 8 lines
---
 drivers/iio/accel/fxls8962af-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/iio/accel/fxls8962af-core.c

drivers/iio/accel/fxls8962af-core.c static int fxls8962af_i2c_raw_read_errata3(struct

Quoted 4 lines

index 078d87865fde..8af1c8f58e83 100644

drivers/iio/accel/fxls8962af-core.c +0 -0
@@ -628,7 +628,7 @@ static int fxls8962af_i2c_raw_read_errata3(struct

fxls8962af_data *data,

Quoted 8 lines
drivers/iio/accel/fxls8962af-core.c +1 -1
                                           u16 *buffer, int samples,
                                           int sample_length)
 {
-       int i, ret;
+       int i, ret = -EINVAL;
 
        for (i = 0; i < samples; i++) {
                ret = regmap_raw_read(data->regmap, FXLS8962AF_BUF_X_LSB,
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Would the change below work?

This function returns -ERRNO when failed. If it is not entering loop, ideally it should return -ERRNO, not 0. No ?

samples can't be 0, as fxls8962af_fifo_transfer() is never called if samples are 0 :)

Yeah, you're right. Smatch can figure that out if you build the cross function DB, but it's a little bit trick for kbuild to use the DB when it runs on so many git trees. The DB takes hours to build so kbuild doesn't use it.

regards,
dan carpenter