Re: [bug report] staging:iio:sca3000 extract old event handling and move to poll for events from buffer

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

 



On Thu, Jun 3, 2021 at 7:38 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
> On Fri, 28 May 2021 15:00:52 +0300
> Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:

...

> >    733                          *val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF;
> >    734                          *val = ((*val) << (sizeof(*val) * 8 - 13)) >>
> >                                                   ^^^^^^^^^^^^^^^^^^^^^^^
> >    735                                  (sizeof(*val) * 8 - 13);
> >                                         ^^^^^^^^^^^^^^^^^^^^^^^
> >
> > This code works, but it relies on undefined behavior of left shift
> > overflow and it's very unsatisfying.  Pretty sure there is a UBSan
> > warning for this at runtime.
>
> Thanks Dan.  Looks like a slightly odd variant on open coded sign_extend32()
> Should be fine to replace with
>
> *val = sign_extend32(*val, 13);

Oh, indeed.

-- 
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