Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Nathan Chancellor <natechancellor@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Kees Cook <keescook@chromium.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-rdma@vger.kernel.org, clang-built-linux@googlegroups.com
Subject: Re: remaining flexible-array conversions
Date: Fri, 24 Apr 2020 10:17:51 -0500	[thread overview]
Message-ID: <f636ad65-b313-90e9-557b-856d44c2e14b@embeddedor.com> (raw)
In-Reply-To: <20200424034704.GA12320@ubuntu-s3-xlarge-x86>

Hi Nathan,

On 4/23/20 22:47, Nathan Chancellor wrote:
> Hi Gustavo,
> 
> That patch in -next appears to introduce some warnings with clang when
> CONFIG_UAPI_HEADER_TEST is enabled (allyesconfig/allmodconfig exposed it
> for us with KernelCI [1]):
> 

Thanks a lot for reporting this.

> ./usr/include/rdma/ib_user_verbs.h:436:34: warning: field 'base' with
> variable sized type 'struct ib_uverbs_create_cq_resp' not at the end of
> a struct or class is a GNU extension
> [-Wgnu-variable-sized-type-not-at-end]
>         struct ib_uverbs_create_cq_resp base;
>                                         ^
> ./usr/include/rdma/ib_user_verbs.h:647:34: warning: field 'base' with
> variable sized type 'struct ib_uverbs_create_qp_resp' not at the end of
> a struct or class is a GNU extension
> [-Wgnu-variable-sized-type-not-at-end]
>         struct ib_uverbs_create_qp_resp base;
>                                         ^
> ./usr/include/rdma/ib_user_verbs.h:743:29: warning: field 'base' with
> variable sized type 'struct ib_uverbs_modify_qp' not at the end of a
> struct or class is a GNU extension
> [-Wgnu-variable-sized-type-not-at-end]
>         struct ib_uverbs_modify_qp base;
>                                    ^
> 3 warnings generated.
> 
> I presume this is part of the point of the conversion since you mention
> a compiler warning when the flexible member is not at the end of a
> struct. How should they be fixed? That should probably happen before the
> patch gets merged.
> 
For all the cases above, the solution seems to be to move the declaration
of the "base" member to the end of the corresponding structure, as below:

diff --git a/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h
index a390a667b3f3..e05538be8b30 100644
--- a/include/uapi/rdma/ib_user_verbs.h
+++ b/include/uapi/rdma/ib_user_verbs.h
@@ -644,9 +644,9 @@ struct ib_uverbs_create_qp_resp {
 };

 struct ib_uverbs_ex_create_qp_resp {
-       struct ib_uverbs_create_qp_resp base;
        __u32 comp_mask;
        __u32 response_length;
+       struct ib_uverbs_create_qp_resp base;
 };

 /*

but I guess this will change the ABI?

Also, notice that:

"A structure containing a flexible array member, or a union containing
such a structure (possibly recursively), may not be a member of a structure
or an element of an array. (However, these uses are permitted by GCC as
extensions.)"[1]

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

Thanks
--
Gustavo

      parent reply	other threads:[~2020-04-24 16:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6342c465-e34b-3e18-cc31-1d989926aebd@embeddedor.com>
2020-04-24  3:47 ` remaining flexible-array conversions Nathan Chancellor
2020-04-24 12:15   ` Jason Gunthorpe
2020-04-24 15:24     ` Kees Cook
2020-04-24 15:36       ` Gustavo A. R. Silva
2020-10-08 15:24     ` Jan Engelhardt
2020-10-08 15:54       ` Jason Gunthorpe
2020-04-24 15:17   ` Gustavo A. R. Silva [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f636ad65-b313-90e9-557b-856d44c2e14b@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox