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