Fit line in 80 columns
PATCH 1/1 Fit line in 80 columns
That line is used to generate the bpf-helpers(7) manual page. It is a no-fill line, since it represents a command, which means that the formatter can't break the line, and instead just runs across the right margin (in most set-ups this means that the pager will break the line).
Using <fmt> makes it end exactly at the 80-col right margin, both in the header file, and also in the manual page, and also seems to be a sensible name.
---
Hi,
We are adding another linter to the manual pages, which lints about output going past the right margin of the terminal.
The following results triggered in the bpf-helpers(7) page:
$ make lint-man-groff LINT (groff) tmp/lint/man7/bpf-helpers.7.lint-man.groff.touch an.tmac:man7/bpf-helpers.7:3: style: .TH missing third argument; suggest document modification date in ISO 8601 format (YYYY-MM-DD) an.tmac:man7/bpf-helpers.7:3: style: .TH missing fourth argument; suggest package/project name and version (e.g., "groff 1.23.0") an.tmac:man7/bpf-helpers.7:3: style: .TH missing fifth argument and second argument '7' not a recognized manual section; specify volume title 114: telnet-470 [001] .N.. 419421.045894: 0x00000001: <formatted msg> 2642: int res = bpf_probe_read_user_str(buf, sizeof(buf), found style problems; aborting make: *** [lib/lint-man.mk:50: tmp/lint/man7/bpf-helpers.7.lint-man.groff.touch] Error 1
This patch addresses the issue in line 114 (that line count is in the output rendered page, not in the man(7) source file).
I'm not sure which of those files are used to produce the manual page, but for consistency I thought it was best to fix both in the same way.
Cheers,
Alex
include/uapi/linux/bpf.h | 5 ++--- tools/include/uapi/linux/bpf.h | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)
include/uapi/linux/bpf.h +2 -3
@@ -1619,7 +1619,7 @@ union bpf_attr {* * :: * -* telnet-470 [001] .N.. 419421.045894: 0x00000001: <formatted msg> +* telnet-470 [001] .N.. 419421.045894: 0x00000001: <fmt> * * In the above: *
@@ -1636,8 +1636,7 @@ union bpf_attr {* * ``419421.045894`` is a timestamp. * * ``0x00000001`` is a fake value used by BPF for the * instruction pointer register. -* * ``<formatted msg>`` is the message formatted with -* *fmt*. +* * ``<fmt>`` is the message formatted with *fmt*. * * The conversion specifiers supported by *fmt* are similar, but * more limited than for printk(). They are **%d**, **%i**,
tools/include/uapi/linux/bpf.h +2 -3
@@ -1619,7 +1619,7 @@ union bpf_attr {* * :: * -* telnet-470 [001] .N.. 419421.045894: 0x00000001: <formatted msg> +* telnet-470 [001] .N.. 419421.045894: 0x00000001: <fmt> * * In the above: *
@@ -1636,8 +1636,7 @@ union bpf_attr {* * ``419421.045894`` is a timestamp. * * ``0x00000001`` is a fake value used by BPF for the * instruction pointer register. -* * ``<formatted msg>`` is the message formatted with -* *fmt*. +* * ``<fmt>`` is the message formatted with *fmt*. * * The conversion specifiers supported by *fmt* are similar, but * more limited than for printk(). They are **%d**, **%i**,
Signature · 1 line
2.37.2
Quoted 10 lines · Alejandro Colomar
That line is used to generate the bpf-helpers(7) manual page. It is a no-fill line, since it represents a command, which means that the formatter can't break the line, and instead just runs across the right margin (in most set-ups this means that the pager will break the line).
Using <fmt> makes it end exactly at the 80-col right margin, both in the header file, and also in the manual page, and also seems to be a sensible name.
Nack.
We don't follow 80 char limit and are not going to because of man pages.
Quoted 10 lines · Alexei Starovoitov
Quoted 7 lines · Alejandro Colomar
That line is used to generate the bpf-helpers(7) manual page. It is a no-fill line, since it represents a command, which means that the formatter can't break the line, and instead just runs across the right margin (in most set-ups this means that the pager will break the line).
Quoted 7 lines
Quoted 3 lines
Using <fmt> makes it end exactly at the 80-col right margin, both in the header file, and also in the manual page, and also seems to be a sensible name.
Nack.
We don't follow 80 char limit and are not going to because of man pages.
And it's questionable in general to enforce line length for verbatim (code) block. It's verbatim for a good reason, it can't be wrapped.
Hi Andrii and Alexei,
Quoted 16 lines · Andrii Nakryiko
Quoted 14 lines · Alexei Starovoitov
Quoted 10 lines · Alejandro Colomar
That line is used to generate the bpf-helpers(7) manual page. It is a no-fill line, since it represents a command, which means that the formatter can't break the line, and instead just runs across the right margin (in most set-ups this means that the pager will break the line).
Using <fmt> makes it end exactly at the 80-col right margin, both in the header file, and also in the manual page, and also seems to be a sensible name.
Quoted 6 lines
Quoted 3 lines
Nack.
We don't follow 80 char limit and are not going to because of man pages.
And it's questionable in general to enforce line length for verbatim (code) block. It's verbatim for a good reason, it can't be wrapped.
That's why instead of wrapping, I reduced the length of some "identifier". It's not enforced, but it's nicer if it fits. There are several other cases, where it wasn't easy to make it shorter, and I left it exceeding the margin.
It's not so crucial to fix it, and if you prefer it like it is currently, it's reasonable. This is a suggestion, to make it easier to read.
Cheers,
Alex
Signature · 2 lines
Alejandro Colomar <http://www.alejandro-colomar.es/>
Quoted 11 lines · Alejandro Colomar
Quoted 6 lines · Andrii Nakryiko
Quoted 1 line · Alexei Starovoitov
We don't follow 80 char limit and are not going to because of man pages.
And it's questionable in general to enforce line length for verbatim (code) block. It's verbatim for a good reason, it can't be wrapped.
That's why instead of wrapping, I reduced the length of some "identifier". It's not enforced, but it's nicer if it fits. There are several other cases, where it wasn't easy to make it shorter, and I left it exceeding the margin.
It's not so crucial to fix it, and if you prefer it like it is currently, it's reasonable. This is a suggestion, to make it easier to read.
As an example, you can see this commit recently applied to the man-pages:
I only made lines shorter in cases where no info was lost (including format).
Signature · 2 lines
Alejandro Colomar <http://www.alejandro-colomar.es/>
[sorry for the big CC]
Quoted 4 lines · Alexei Starovoitov
Nack.
We don't follow 80 char limit and are not going to because of man pages.
If someone got a contract with O'Reilly or No Starch Press to write a book on BPF and how revolutionarily awesome it is, it's conceivable they would be faced with exposing some BPF-related function declarations in the text. In cases like the following, what would you have them do?
int bpf_map_update_elem(struct bpf_map *map, const void *key, const void *value, u64 flags)
Be aware that the author may not have infinite flexibility; publishers generally impose a "house style" which restricts selection of typeface (so they can't necessarily print at a smaller type size or with the kerning reduced beyond a certain point to squeeze the text onto the line).
Regards,
Branden
Quoted 6 lines · G. Branden Robinson
[sorry for the big CC]
Quoted 2 lines · Alexei Starovoitov
Nack.
Quoted 7 lines
Quoted 2 lines
We don't follow 80 char limit and are not going to because of man pages.
If someone got a contract with O'Reilly or No Starch Press to write a book on BPF and how revolutionarily awesome it is, it's conceivable they would be faced with exposing some BPF-related function declarations in the text. In cases like the following, what would you have them do?
If they're using a script to write a book their contract should probably be revoked.
Quoted 6 lines · G. Branden Robinson
If someone got a contract with O'Reilly or No Starch Press to write a book on BPF and how revolutionarily awesome it is, it's conceivable they would be faced with exposing some BPF-related function declarations in the text. In cases like the following, what would you have them do?
int
bpf_map_update_elem(struct bpf_map *map, const void *key, const void *value, u64 flags)
I imagine that the author or editor would break it over two lines like
int bpf_map_update_elem(struct bpf_map *map, const void *key,
const void *value, u64 flags)
or maybe the slightly uglier
int bpf_map_update_elem(struct bpf_map *map, const void *key,
const void *value, u64 flags)
I just looked in _Advanced Programming in the Unix Environment, Third Edition_ by Stevens and Rago (published by Addison Wesley rather than either of the fine publishers you mentioned), and it didn't take long to find a C function prototype that was split across two lines in the former style, on p. 880
sem_t *sem_open(const char *name, int oflag, ... /* mode_t mode,
unsigned int value */ );
... or on the next page, a better example because of the absence of the comment:
ssize_t sendto(int sockfd, const void *buf, size_t nbytes, int flags,
const struct sockaddr *destaddr, socklen_t destlen);
It's convenient that C's rules for whitespace semantics make all of these line-wrapped prototypes have exactly the same meaning as their un-line-wrapped equivalents, so programmers reading the books shouldn't have cause to be confused by this. It could be more challenging in a language like Python, although there, too, there are syntactically valid ways to break up some kinds of long lines.
Quoted 13 lines · G. Branden Robinson
[sorry for the big CC]
Quoted 4 lines · Alexei Starovoitov
Nack.
We don't follow 80 char limit and are not going to because of man pages.
If someone got a contract with O'Reilly or No Starch Press to write a book on BPF and how revolutionarily awesome it is, it's conceivable they would be faced with exposing some BPF-related function declarations in the text. In cases like the following, what would you have them do?
Quoted 7 lines
int
bpf_map_update_elem(struct bpf_map *map, const void *key, const void *value, u64 flags)Be aware that the author may not have infinite flexibility; publishers generally impose a "house style" which restricts selection of typeface (so they can't necessarily print at a smaller type size or with the kerning reduced beyond a certain point to squeeze the text onto the line).
As someone who has written a book for one of those publishers you mention above, this is totally not an issue at all. Authors and typesetters know how to properly wrap and handle stuff like this automatically, it's what they do and has nothing to do with how kernel header files are layed out.
But even then, if it was an issue, we don't write kernel code for "some potential commercial entity that can't handle long lines", you know better than this :)
greg k-h
PATCH v2 1/1 Fit lines in 80 columns
In reply to Alejandro ColomarThose lines is used to generate the bpf-helpers(7) manual page. They are no-fill lines, since they represent code, which means that the formatter can't break the line, and instead just runs across the right margin (in most set-ups this means that the pager will break the line).
Using <fmt> makes it end exactly at the 80-col right margin, both in the header file, and also in the manual page, and also seems to be a sensible name to me.
In the other case, the fix has been to separate the variable definition and its use, as the kernel coding style recommends.
--- include/uapi/linux/bpf.h | 11 ++++++----- tools/include/uapi/linux/bpf.h | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-)
include/uapi/linux/bpf.h +6 -5
@@ -1619,7 +1619,7 @@ union bpf_attr {* * :: * -* telnet-470 [001] .N.. 419421.045894: 0x00000001: <formatted msg> +* telnet-470 [001] .N.. 419421.045894: 0x00000001: <fmt> * * In the above: *
@@ -1636,8 +1636,7 @@ union bpf_attr {* * ``419421.045894`` is a timestamp. * * ``0x00000001`` is a fake value used by BPF for the * instruction pointer register. -* * ``<formatted msg>`` is the message formatted with -* *fmt*. +* * ``<fmt>`` is the message formatted with *fmt*. * * The conversion specifiers supported by *fmt* are similar, but * more limited than for printk(). They are **%d**, **%i**,
@@ -3860,8 +3859,10 @@ union bpf_attr {* void bpf_sys_open(struct pt_regs *ctx) * { * char buf[PATHLEN]; // PATHLEN is defined to 256 -* int res = bpf_probe_read_user_str(buf, sizeof(buf), -* ctx->di); +* int res; +* +* res = bpf_probe_read_user_str(buf, sizeof(buf), +* ctx->di); * * // Consume buf, for example push it to * // userspace via bpf_perf_event_output(); we
tools/include/uapi/linux/bpf.h +6 -5
@@ -1619,7 +1619,7 @@ union bpf_attr {* * :: * -* telnet-470 [001] .N.. 419421.045894: 0x00000001: <formatted msg> +* telnet-470 [001] .N.. 419421.045894: 0x00000001: <fmt> * * In the above: *
@@ -1636,8 +1636,7 @@ union bpf_attr {* * ``419421.045894`` is a timestamp. * * ``0x00000001`` is a fake value used by BPF for the * instruction pointer register. -* * ``<formatted msg>`` is the message formatted with -* *fmt*. +* * ``<fmt>`` is the message formatted with *fmt*. * * The conversion specifiers supported by *fmt* are similar, but * more limited than for printk(). They are **%d**, **%i**,
@@ -3860,8 +3859,10 @@ union bpf_attr {* void bpf_sys_open(struct pt_regs *ctx) * { * char buf[PATHLEN]; // PATHLEN is defined to 256 -* int res = bpf_probe_read_user_str(buf, sizeof(buf), -* ctx->di); +* int res; +* +* res = bpf_probe_read_user_str(buf, sizeof(buf), +* ctx->di); * * // Consume buf, for example push it to * // userspace via bpf_perf_event_output(); we
Signature · 1 line
2.37.2
Daniel Borkmann
maintainerRe: [PATCH v2] Fit lines in 80 columns
Quoted 60 lines · Alejandro Colomar
Those lines is used to generate the bpf-helpers(7) manual page. They are no-fill lines, since they represent code, which means that the formatter can't break the line, and instead just runs across the right margin (in most set-ups this means that the pager will break the line).
Using <fmt> makes it end exactly at the 80-col right margin, both in the header file, and also in the manual page, and also seems to be a sensible name to me.
In the other case, the fix has been to separate the variable definition and its use, as the kernel coding style recommends.
Nacked-by Alexei Starovoitov <[email protected]>Cc bpf <[email protected]>Cc linux-man <[email protected]>Cc Daniel Borkmann <[email protected]>Cc Andrii Nakryiko <[email protected]>Cc Martin KaFai Lau <[email protected]>Cc Song Liu <[email protected]>Cc Yonghong Song <[email protected]>Cc John Fastabend <[email protected]>Cc KP Singh <[email protected]>Cc Stanislav Fomichev <[email protected]>Cc Hao Luo <[email protected]>Cc Jiri Olsa <[email protected]>Cc Jesper Dangaard Brouer <[email protected]>Cc Quentin Monnet <[email protected]>Cc Greg KH <[email protected]>Cc "G. Branden Robinson" <[email protected]>Signed-off-by Alejandro Colomar <[email protected]>--- include/uapi/linux/bpf.h | 11 ++++++----- tools/include/uapi/linux/bpf.h | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-)include/uapi/linux/bpf.h +2
-3@@ -1619,7 +1619,7 @@ union bpf_attr {* * :: * -* telnet-470 [001] .N.. 419421.045894: 0x00000001: <formatted msg> +* telnet-470 [001] .N.. 419421.045894: 0x00000001: <fmt> * * In the above: * @@ -1636,8 +1636,7 @@ union bpf_attr {* * ``419421.045894`` is a timestamp. * * ``0x00000001`` is a fake value used by BPF for the * instruction pointer register. -* * ``<formatted msg>`` is the message formatted with -* *fmt*. +* * ``<fmt>`` is the message formatted with *fmt*. * * The conversion specifiers supported by *fmt* are similar, but * more limited than for printk(). They are **%d**, **%i**,
include/uapi/linux/bpf.h union bpf_attr { · line 3866
Quoted 10 lines
include/uapi/linux/bpf.h +4
-2@@ -3860,8 +3859,10 @@ union bpf_attr {* void bpf_sys_open(struct pt_regs *ctx) * { * char buf[PATHLEN]; // PATHLEN is defined to 256 -* int res = bpf_probe_read_user_str(buf, sizeof(buf), -* ctx->di); +* int res; +* +* res = bpf_probe_read_user_str(buf, sizeof(buf), +* ctx->di); *
Aside that this has been Nacked before, this looks really ugly. I'm not applying this, sorry.
Thanks,
Daniel