Re: [PATCH] RDMA/mlx5: hide unused code
From: Jason Gunthorpe
Date: Fri Mar 28 2025 - 09:15:28 EST
On Fri, Mar 28, 2025 at 02:10:17PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> After a recent rework, a few 'static const' objects have become unused:
>
> In file included from drivers/infiniband/hw/mlx5/fs.c:27:
> drivers/infiniband/hw/mlx5/fs.c:26:28: error: 'mlx5_ib_object_MLX5_IB_OBJECT_STEERING_ANCHOR' defined but not used [-Werror=unused-const-variable=]
> include/rdma/uverbs_named_ioctl.h:52:47: note: in expansion of macro 'UVERBS_OBJECT'
> 52 | static const struct uverbs_object_def UVERBS_OBJECT(_object_id) = { \
> | ^~~~~~~~~~~~~
> drivers/infiniband/hw/mlx5/fs.c:3457:1: note: in expansion of macro 'DECLARE_UVERBS_NAMED_OBJECT'
> 3457 | DECLARE_UVERBS_NAMED_OBJECT(
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> drivers/infiniband/hw/mlx5/fs.c:26:28: error: 'mlx5_ib_object_MLX5_IB_OBJECT_FLOW_MATCHER' defined but not used [-Werror=unused-const-variable=]
> include/rdma/uverbs_named_ioctl.h:52:47: note: in expansion of macro 'UVERBS_OBJECT'
> 52 | static const struct uverbs_object_def UVERBS_OBJECT(_object_id) = { \
> | ^~~~~~~~~~~~~
> drivers/infiniband/hw/mlx5/fs.c:3429:1: note: in expansion of macro 'DECLARE_UVERBS_NAMED_OBJECT'
> 3429 | DECLARE_UVERBS_NAMED_OBJECT(MLX5_IB_OBJECT_FLOW_MATCHER,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> These come from a complex set of macros, and it would be possible to
> shut up the warnings here by adding __maybe_unused annotations inside
> of the macros, it seems cleaner in this case to have a large #ifdef block
> around all the unused parts of the file, in order to still be able to
> catch unused ones elsewhere.
IDK, I'm tempted to revert 36e0d433672f ("RDMA/mlx5: Compile fs.c
regardless of INFINIBAND_USER_ACCESS config")
I don't think that was so well thought out. The entire file was
designed to be USER_ACCESS only because it uses all this mechanism.
#ifdefing away half the file seems ugly.
Jason