Re: [PATCH] rds: ib: force endiannes annotation

From: Edward Cree
Date: Mon Apr 29 2019 - 08:02:46 EST


On 29/04/2019 12:18, Nicholas Mc Guire wrote:
> On Mon, Apr 29, 2019 at 12:00:06PM +0100, Edward Cree wrote:
>> Again, a __force cast doesn't seem necessary here. It looks like the
>> Âcode is just using the wrong types; if all of src, dst and uncongested
>> Âwere __le64 instead of uint64_t, and the last two lines replaced with
>> Ârds_cong_map_updated(map, le64_to_cpu(uncongested)); then the semantics
>> Âwould be kept with neither sparse errors nor __force.
>>
>> __force is almost never necessary and mostly just masks other bugs or
>> Âendianness confusion in the surrounding code. Instead of adding a
>> Â__force, either fix the code to be sparse-clean or leave the sparse
>> Âwarning in place so that future developers know there's something not
>> Âright.
>>
> changing uncongested to __le64 is not an option here - it would only move
> the sparse warnings to those other locatoins where the ports that
> became uncongested are being or'ed into uncongested.
That's why I say to change *src and *dst too. Sparse won't mind the
Âconversion from void * to __le64 * when they're assigned, and the only
Âoperations we do on them...
> uncongested |= ~(*src) & *dst;
> *dst++ = *src++;
... are some bitwise ops on the values (bitwise ops are legal in any
Âendianness) and incrementation of the pointers (which cares only about
Âthe pointee size, not type).

-Ed