On Mon, Feb 24, 2025 at 3:15 PM Ihor Solodrai <ihor.solodrai@xxxxxxxxx> wrote: > > On 2/24/25 2:05 PM, Andrii Nakryiko wrote: > > > [...] > > > > arg_bitshift is stored as char (which could be signed), so that's why > > you were getting signed division, just cast to unsigned and keep > > division: > > > > return (64 - (unsigned)arg_spec->arg_bitshift) / 8; > > As it turns out, this doesn't work either. Presumably because > (64 - (u8)x) is still a signed int. hm... ok, surprising, but fine > > This works, however: > > return (unsigned char)(64 - arg_spec->arg_bitshift) / 8; > nit: just unsigned (int), BPF doesn't have single-byte division anyways, so it will be upconverted to 32-bit (or 64-bit for noalu32). So let's be bold and use 32-bits here ;) > > > >> [...]