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

From: Edward Cree
Date: Mon Apr 29 2019 - 07:00:15 EST


On 29/04/2019 07:09, Nicholas Mc Guire wrote:
> diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
> index 7055985..a070a2d 100644
> --- a/net/rds/ib_recv.c
> +++ b/net/rds/ib_recv.c
> @@ -824,7 +824,7 @@ static void rds_ib_cong_recv(struct rds_connection *conn,
> }
>
> /* the congestion map is in little endian order */
> - uncongested = le64_to_cpu(uncongested);
> + uncongested = le64_to_cpu((__force __le64)uncongested);
>
> rds_cong_map_updated(map, uncongested);
> }
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.

-Ed