bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Stephen Kitt <steve@sk2.org>, Alexei Starovoitov <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	Martin Lau <kafai@fb.com>, Yonghong Song <yhs@fb.com>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>
Subject: Re: [PATCH] bpf: use flexible array members, not zero-length
Date: Mon, 30 Sep 2019 06:07:47 +0000	[thread overview]
Message-ID: <F15E974F-4B7F-4819-B640-682A0A3A47C5@fb.com> (raw)
In-Reply-To: <02a551bc-7551-7c0e-0215-5ac8856b0512@embeddedor.com>



> On Sep 28, 2019, at 10:49 PM, Gustavo A. R. Silva <gustavo@embeddedor.com> wrote:
> 
> 
> 
> On 9/28/19 09:48, Stephen Kitt wrote:
>> This switches zero-length arrays in variable-length structs to C99
>> flexible array members. GCC will then ensure that the arrays are
>> always the last element in the struct.
>> 
>> Coccinelle:
>> @@
>> identifier S, fld;
>> type T;
>> @@
>> 
>> struct S {
>>  ...
>> - T fld[0];
>> + T fld[];
>>  ...
>> };
>> 
>> Signed-off-by: Stephen Kitt <steve@sk2.org>
>> ---
>> Documentation/bpf/btf.rst       | 2 +-
>> tools/lib/bpf/libbpf.c          | 2 +-
>> tools/lib/bpf/libbpf_internal.h | 2 +-
>> 3 files changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/Documentation/bpf/btf.rst b/Documentation/bpf/btf.rst
>> index 4d565d202ce3..24ce50fc1fc1 100644
>> --- a/Documentation/bpf/btf.rst
>> +++ b/Documentation/bpf/btf.rst
>> @@ -670,7 +670,7 @@ func_info for each specific ELF section.::
>>         __u32   sec_name_off; /* offset to section name */
>>         __u32   num_info;
>>         /* Followed by num_info * record_size number of bytes */
>> -        __u8    data[0];
>> +        __u8    data[];
>>      };
>> 
>> Here, num_info must be greater than 0.
>> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
>> index e0276520171b..c02ea0e1a588 100644
>> --- a/tools/lib/bpf/libbpf.c
>> +++ b/tools/lib/bpf/libbpf.c
>> @@ -5577,7 +5577,7 @@ static struct perf_buffer *__perf_buffer__new(int map_fd, size_t page_cnt,
>> struct perf_sample_raw {
>> 	struct perf_event_header header;
>> 	uint32_t size;
>> -	char data[0];
>> +	char data[];
>> };
>> 
>> struct perf_sample_lost {
>> diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
>> index 2e83a34f8c79..26eaa3f594aa 100644
>> --- a/tools/lib/bpf/libbpf_internal.h
>> +++ b/tools/lib/bpf/libbpf_internal.h
>> @@ -86,7 +86,7 @@ struct btf_ext_info_sec {
>> 	__u32	sec_name_off;
>> 	__u32	num_info;
>> 	/* Followed by num_info * record_size number of bytes */
>> -	__u8	data[0];
>> +	__u8 data[];
> 
> I think you should preserve the tab here.

Agreed. 

Besides this:

Acked-by: Song Liu <songliubraving@fb.com>


  reply	other threads:[~2019-09-30  6:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-28 14:48 [PATCH] bpf: use flexible array members, not zero-length Stephen Kitt
2019-09-29  5:49 ` Gustavo A. R. Silva
2019-09-30  6:07   ` Song Liu [this message]
2019-09-30  7:38     ` [PATCH v2] " Stephen Kitt
2019-09-30 23:18       ` Gustavo A. R. Silva
2019-09-30  7:41     ` [PATCH] " Stephen Kitt
2019-09-30  8:50 ` Daniel Borkmann

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=F15E974F-4B7F-4819-B640-682A0A3A47C5@fb.com \
    --to=songliubraving@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=gustavo@embeddedor.com \
    --cc=kafai@fb.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=steve@sk2.org \
    --cc=yhs@fb.com \
    /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;
as well as URLs for NNTP newsgroup(s).