Re: [PATCH v1 4/5] iio: pressure: bmp280: Drop unneeded explicit castings

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

 



On Sun, Mar 22, 2020 at 7:24 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
> On Tue, 17 Mar 2020 12:18:12 +0200
> Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> > In few places the unnecessary explicit castings are being used.
> > Drop them for good.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
>
> A passing comment inline, but seems sensible to me.

...

> > +     ret = regmap_bulk_read(data->regmap, BMP280_REG_PRESS_MSB, &tmp, 3);

(left for a context)

...

> > +     __be16 tmp;
> >       int ret;
> > -     __be16 tmp = 0;
>
> I haven't checked it but normally that sort of initialization got added
> because a compiler got 'clever' and decided that it might be used uninitialized.
>
> However, it's a bit odd in this case as there are lots of other calls
> of the same thing that don't bother initializing.  So must not be that...

When it's 3 bytes read (24 bit) it's required to get correct sign from
the value or in general to avoid garbage in one byte.
But here are two bytes to read to the 16 bit variable. No
initialization required.

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux