Re: [PATCH v2] IB/mlx5: avoid bogus -Wmaybe-uninitialized warning
From: Doug Ledford
Date: Wed Dec 14 2016 - 12:13:35 EST
On 10/24/2016 4:48 PM, Arnd Bergmann wrote:
> We get a false-positive warning in linux-next for the mlx5 driver:
>
> infiniband/hw/mlx5/mr.c: In function âmlx5_ib_reg_user_mrâ:
> infiniband/hw/mlx5/mr.c:1172:5: error: âorderâ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> infiniband/hw/mlx5/mr.c:1161:6: note: âorderâ was declared here
> infiniband/hw/mlx5/mr.c:1173:6: error: âncontâ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> infiniband/hw/mlx5/mr.c:1160:6: note: âncontâ was declared here
> infiniband/hw/mlx5/mr.c:1173:6: error: âpage_shiftâ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> infiniband/hw/mlx5/mr.c:1158:6: note: âpage_shiftâ was declared here
> infiniband/hw/mlx5/mr.c:1143:13: error: ânpagesâ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> infiniband/hw/mlx5/mr.c:1159:6: note: ânpagesâ was declared here
>
> I had a trivial workaround for gcc-5 or higher, but that didn't work
> on gcc-4.9 unfortunately.
>
> The only way I found to avoid the warnings for gcc-4.9, short of
> initializing each of the arguments first was to change the calling
> conventions to separate the error code from the umem pointer. This
> avoids casting the error codes from one pointer to another incompatible
> pointer, and lets gcc figure out when that the data is actually valid
> whenever we return successfully.
>
> Acked-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Thanks, applied (with fixups due to conflicts).
--
Doug Ledford <dledford@xxxxxxxxxx>
GPG Key ID: 0E572FDD
Attachment:
signature.asc
Description: OpenPGP digital signature