All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Jan Engelhardt <jengelh@inai.de>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Subject: Re: [iptables PATCH] libiptc: Avoid gcc-10 zero-length array warning
Date: Thu, 8 Oct 2020 16:58:22 +0200	[thread overview]
Message-ID: <20201008145822.GA13016@orbyte.nwl.cc> (raw)
In-Reply-To: <s95qopq1-3o5o-oo9-1qso-osp024914p67@vanv.qr>

Hi Jan,

On Thu, Oct 08, 2020 at 04:33:04PM +0200, Jan Engelhardt wrote:
[...]
> Anyway, gcc-10/C mode does not reject embedding (and a number of maintainers
> have made it abundantly clear in the past they don't care if UAPI uses anti-C++
> "features"). Nonreject example:
> 
> » cat x.c
> struct a2 {
>         int x;
>         int z[];
> };
> struct m {
>         struct a2 y;
>         long q;
> };
> » gcc -Wall -std=c11 -c -w -v x.c
> GNU C11 (SUSE Linux) version 10.2.1 20200825 [revision c0746a1beb1ba073c7981eb09f55b3d993b32e5c] (x86_64-suse-linux)

No need to pass '-w', gcc seems to accept the above unless one passes
'-pedantic' and thereby enables strict ISO C mode:

| % gcc -Wall -pedantic -std=c11 -c x.c   
| x.c:6:19: warning: invalid use of structure with flexible array member [-Wpedantic]
|     6 |         struct a2 y;
|       |                   ^

While the question of whether kernel UAPI headers should adhere to
strict ISO C or not may be debatable, my motivation for working around
the situation in user space comes from Gustavo's complaints when I tried
to convert the relevant struct members into flexible arrays. He
apparently is a burnt child looking at commit 1e6e9d0f4859e ("uapi:
revert flexible-array conversions").

Cheers, Phil

  reply	other threads:[~2020-10-08 14:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08 13:01 [iptables PATCH] libiptc: Avoid gcc-10 zero-length array warning Phil Sutter
2020-10-08 14:33 ` Jan Engelhardt
2020-10-08 14:58   ` Phil Sutter [this message]
2020-10-08 15:31     ` Jan Engelhardt
2020-10-08 16:07       ` Phil Sutter
2020-10-08 16:46         ` Jan Engelhardt
2020-10-09 15:16           ` Phil Sutter
2020-10-09 16:43             ` Jan Engelhardt

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=20201008145822.GA13016@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=jengelh@inai.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.