diff mbox

iio temperature/mlx90632: silence a static checker warning

Message ID 20180222091453.GC9883@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Feb. 22, 2018, 9:14 a.m. UTC
This shouldn't affect runtime at all, but Smatch complains that we
should check if mlx90632_read_ambient_raw() otherwise we
"ambient_new_raw" can be uninitialized.

    drivers/iio/temperature/mlx90632.c:509 mlx90632_calc_ambient_dsp105()
    error: uninitialized symbol 'ambient_new_raw'.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Crt Mori Feb. 22, 2018, 9:26 a.m. UTC | #1
OK, makes sense.

Acked-by: Crt Mori <cmo@melexis.com>

On 22 February 2018 at 10:14, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> This shouldn't affect runtime at all, but Smatch complains that we
> should check if mlx90632_read_ambient_raw() otherwise we
> "ambient_new_raw" can be uninitialized.
>
>     drivers/iio/temperature/mlx90632.c:509 mlx90632_calc_ambient_dsp105()
>     error: uninitialized symbol 'ambient_new_raw'.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
> index d695ab97d27f..9851311aa3fd 100644
> --- a/drivers/iio/temperature/mlx90632.c
> +++ b/drivers/iio/temperature/mlx90632.c
> @@ -506,6 +506,8 @@ static int mlx90632_calc_ambient_dsp105(struct mlx90632_data *data, int *val)
>
>         ret = mlx90632_read_ambient_raw(data->regmap, &ambient_new_raw,
>                                         &ambient_old_raw);
> +       if (ret < 0)
> +               return ret;
>         *val = mlx90632_calc_temp_ambient(ambient_new_raw, ambient_old_raw,
>                                           PT, PR, PG, PO, Gb);
>         return ret;
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jonathan Cameron Feb. 24, 2018, 1:35 p.m. UTC | #2
On Thu, 22 Feb 2018 10:26:17 +0100
Crt Mori <cmo@melexis.com> wrote:

> OK, makes sense.
> 
> Acked-by: Crt Mori <cmo@melexis.com>
> 
Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan

> On 22 February 2018 at 10:14, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > This shouldn't affect runtime at all, but Smatch complains that we
> > should check if mlx90632_read_ambient_raw() otherwise we
> > "ambient_new_raw" can be uninitialized.
> >
> >     drivers/iio/temperature/mlx90632.c:509 mlx90632_calc_ambient_dsp105()
> >     error: uninitialized symbol 'ambient_new_raw'.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
> > index d695ab97d27f..9851311aa3fd 100644
> > --- a/drivers/iio/temperature/mlx90632.c
> > +++ b/drivers/iio/temperature/mlx90632.c
> > @@ -506,6 +506,8 @@ static int mlx90632_calc_ambient_dsp105(struct mlx90632_data *data, int *val)
> >
> >         ret = mlx90632_read_ambient_raw(data->regmap, &ambient_new_raw,
> >                                         &ambient_old_raw);
> > +       if (ret < 0)
> > +               return ret;
> >         *val = mlx90632_calc_temp_ambient(ambient_new_raw, ambient_old_raw,
> >                                           PT, PR, PG, PO, Gb);
> >         return ret;  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
index d695ab97d27f..9851311aa3fd 100644
--- a/drivers/iio/temperature/mlx90632.c
+++ b/drivers/iio/temperature/mlx90632.c
@@ -506,6 +506,8 @@  static int mlx90632_calc_ambient_dsp105(struct mlx90632_data *data, int *val)
 
 	ret = mlx90632_read_ambient_raw(data->regmap, &ambient_new_raw,
 					&ambient_old_raw);
+	if (ret < 0)
+		return ret;
 	*val = mlx90632_calc_temp_ambient(ambient_new_raw, ambient_old_raw,
 					  PT, PR, PG, PO, Gb);
 	return ret;