Re: [PATCH rdma-next v1 01/10] RDMA/uverbs: Use C99 flex array syntax for trailing members in uapi headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 22, 2018 at 04:04:52PM +0200, Leon Romanovsky wrote:
> From: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
> 
> The syntax for this construct was standardized as [], not [0]. Use the
> standard syntax in the uapi header.
> 
> Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
>  include/uapi/rdma/ib_user_verbs.h | 54 +++++++++++++++----------------
>  1 file changed, 27 insertions(+), 27 deletions(-)
> 
> diff --git a/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h
> index 1254b51a551a..98e5c12336d6 100644
> +++ b/include/uapi/rdma/ib_user_verbs.h
> @@ -158,7 +158,7 @@ struct ib_uverbs_ex_cmd_hdr {
>  
>  struct ib_uverbs_get_context {
>  	__aligned_u64 response;
> -	__aligned_u64 driver_data[0];
> +	__aligned_u64 driver_data[];
>  };

So.. it turns out that clang doesn't like this syntax. It says that
putting a flex array anyplace but the end of a struct (even if
nesting!) is a GNU extension.

This means these various changes from [0] to [] cause clang to throw
out -Wgnu-variable-sized-type-not-at-end when compiling this header,
and rdma-core just explodes because it has all sorts of places where
it puts the flex array in the middle of the layout, ie it does
something like:

struct foo {
    struct ib_uverbs_get_context core;
    struct mlx5_get_context drv;
}

With the explicit intention of causing core.driver_data to overlap
'drv'.

So I think we should drop this patch and also do s/[]/[0]/g to
'RDMA/uverbs: Add missing driver_data'..

I dislike this because, technically, foo[1] in a [0] array is out of
bounds and static analysis should flag it, while [] is defined to
remove such a bounds check.. Alas.

Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux