From: Coly Li <colyli@suse.de>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>, Jens Axboe <axboe@kernel.dk>,
Kent Overstreet <kmo@daterainc.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [v2] bcache: hide variable-sized types from uapi header check
Date: Mon, 18 Oct 2021 22:20:33 +0800 [thread overview]
Message-ID: <ce05e90b-f22f-bd0e-4e0f-da560bffc0c2@suse.de> (raw)
In-Reply-To: <20210928085554.2299495-1-arnd@kernel.org>
On 9/28/21 4:55 PM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The headers_check helper complains about a GNU extension in
> one of the exported headers:
>
> linux/bcache.h:354:2: warning: field '' with variable sized type 'union jset::(anonymous at ./usr/include/linux/bcache.h:354:2)' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
> BKEY_PADDED(uuid_bucket);
> ^
> linux/bcache.h:134:2: note: expanded from macro 'BKEY_PADDED'
> union { struct bkey key; __u64 key ## _pad[BKEY_PAD]; }
> ^
>
> Address this by enclosing the GNU extensions in an #ifdef: Since the
> header check is done with --std=c90, this shuts up the warning and makes
> it possible to include the header file C90 user space applications, but
> allows applications built with --std=gnu89 or higher to use those
> parts.
>
> Another alternative would be to exclude this header from the check,
> but the GNU extension check seems more sensible.
>
> Fixes: 81ab4190ac17 ("bcache: Pull on disk data structures out into a separate header")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Hi Arnd,
IMHO, remove bcache related header from uapi check might be better
solution. So far only bcache-tools uses this header with its own copy,
no application includes the header(s) so far. It makes sense to exclude
bcache.h from upai headers check.
Thanks.
Coly Li
> ---
> v2: use __STRICT_ANSI__ check instead of __KERNEL__.
>
> I think this version is better than the first, let me know if that
> works for you.
> ---
> include/uapi/linux/bcache.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
> index cf7399f03b71..b7901e986193 100644
> --- a/include/uapi/linux/bcache.h
> +++ b/include/uapi/linux/bcache.h
> @@ -23,9 +23,13 @@ static inline void SET_##name(type *k, __u64 v) \
> struct bkey {
> __u64 high;
> __u64 low;
> +#ifndef __STRICT_ANSI__
> + /* gcc extension not meant for user space */
> __u64 ptr[];
> +#endif
> };
>
> +#ifndef __STRICT_ANSI__
> #define KEY_FIELD(name, field, offset, size) \
> BITMASK(name, struct bkey, field, offset, size)
>
> @@ -127,6 +131,8 @@ static inline struct bkey *bkey_idx(const struct bkey *k, unsigned int nr_keys)
>
> return (struct bkey *) (d + nr_keys);
> }
> +#endif
> +
> /* Enough for a key with 6 pointers */
> #define BKEY_PAD 8
>
next prev parent reply other threads:[~2021-10-18 14:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-28 8:55 Arnd Bergmann
2021-10-18 14:20 ` Coly Li [this message]
2021-10-18 14:39 ` Arnd Bergmann
2021-10-18 14:42 ` Coly Li
2021-10-18 15:18 ` Christoph Hellwig
2021-10-18 15:22 ` Christoph Hellwig
2021-10-18 15:26 ` Coly Li
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=ce05e90b-f22f-bd0e-4e0f-da560bffc0c2@suse.de \
--to=colyli@suse.de \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=axboe@kernel.dk \
--cc=kmo@daterainc.com \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®