Re: [PATCH v3] bpf.2: Use standard types and attributes

From: Daniel Borkmann
Date: Mon May 17 2021 - 14:56:41 EST


On 5/16/21 11:16 AM, Alejandro Colomar (man-pages) wrote:
On 5/15/21 9:01 PM, Alejandro Colomar wrote:
Some manual pages are already using C99 syntax for integral
types 'uint32_t', but some aren't.  There are some using kernel
syntax '__u32'.  Fix those.

Both the kernel and the standard types are 100% binary compatible,
and the source code differences between them are very small, and
not important in a manual page:

- Some of them are implemented with different underlying types
   (e.g., s64 is always long long, while int64_t may be long long
   or long, depending on the arch).  This causes the following
   differences.

- length modifiers required by printf are different, resulting in
   a warning ('-Wformat=').

- pointer assignment causes a warning:
   ('-Wincompatible-pointer-types'), but there aren't any pointers
   in this page.

But, AFAIK, all of those warnings can be safely ignored, due to
the binary compatibility between the types.

...

Some pages also document attributes, using GNU syntax
'__attribute__((xxx))'.  Update those to use the shorter and more
portable C11 keywords such as 'alignas()' when possible, and C2x
syntax '[[gnu::xxx]]' elsewhere, which hasn't been standardized
yet, but is already implemented in GCC, and available through
either --std=c2x or any of the --std=gnu... options.

The standard isn't very clear on how to use alignas() or
[[]]-style attributes, and the GNU documentation isn't better, so
the following link is a useful experiment about the different
alignment syntaxes:
__attribute__((aligned())), alignas(), and [[gnu::aligned()]]:
<https://stackoverflow.com/q/67271825/6872717>

Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx>
Discussion: <https://lore.kernel.org/linux-man/6740a229-842e-b368-86eb-defc786b3658@xxxxxxxxx/T/>
Nacked-by: Alexei Starovoitov <ast@xxxxxxxxxx>
Nacked-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

You forgot to retain my ...

Nacked-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>

Acked-by: Zack Weinberg <zackw@xxxxxxxxx>
Cc: LKML <linux-kernel@xxxxxxxxxxxxxxx>
Cc: glibc <libc-alpha@xxxxxxxxxxxxxx>
Cc: GCC <gcc-patches@xxxxxxxxxxx>
Cc: bpf <bpf@xxxxxxxxxxxxxxx>
Cc: David Laight <David.Laight@xxxxxxxxxx>
Cc: Joseph Myers <joseph@xxxxxxxxxxxxxxxx>
Cc: Florian Weimer <fweimer@xxxxxxxxxx>
Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
---
  man2/bpf.2 | 49 ++++++++++++++++++++++++-------------------------
  1 file changed, 24 insertions(+), 25 deletions(-)