On 10.05.2021 08:36, Christoph Hellwig wrote: > On Sat, May 08, 2021 at 12:29:15AM +0200, Heiner Kallweit wrote: >> + >> + if (len == 4) { >> + put_unaligned_le32(val, buf); >> + } else { >> + cpu_to_le32s(&val); >> + memcpy(buf, (u8 *)&val + skip, len); > > cpu_to_le32s is a horrible API that breaks endianess annotations. > The endian-adjusted value is used just in the next line, so I think there's no risk of wrong usage. But yes, this function converts to le32 w/o using __bitwise. Therefore I understand the concern. > Is the intent of this code to only put 16 bits in? Why not something > like: > > switch (len) { > case 4: > put_unaligned_le32(val, buf); > break; > case 2: > put_unaligned_le16(val, buf + 2); > break; > case 1: > buf[3] = val; > break; > } > len can have any value 1 .. 4. Also the proposal doesn't consider the skip value.