diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-06-04 20:56:29 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-06-06 09:52:52 +0200 |
commit | a5b28b772105ca192aab730c6179722e48999ba3 (patch) | |
tree | 2199f60e5177cfe8d36b1d42d7a8be133b5ebe46 /docs/CODING_STYLE.md | |
parent | 071e522eec2d4f5f29ef929db4bf40af1860fdac (diff) | |
download | systemd-a5b28b772105ca192aab730c6179722e48999ba3.tar.gz |
CODING_STYLE: say that inet_ntop() is a no no
Diffstat (limited to 'docs/CODING_STYLE.md')
-rw-r--r-- | docs/CODING_STYLE.md | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/docs/CODING_STYLE.md b/docs/CODING_STYLE.md index 20e7251491..3599db57fb 100644 --- a/docs/CODING_STYLE.md +++ b/docs/CODING_STYLE.md @@ -645,6 +645,11 @@ SPDX-License-Identifier: LGPL-2.1-or-later `uint16_t`. Also, "network byte order" is just a weird name for "big endian", hence we might want to call it "big endian" right-away. +- Use `typesafe_inet_ntop()`, `typesafe_inet_ntop4()`, and + `typesafe_inet_ntop6()` instead of `inet_ntop()`. But better yet, use the + `IN_ADDR_TO_STRING()`, `IN4_ADDR_TO_STRING()`, and `IN6_ADDR_TO_STRING()` + macros which allocate an anynomous buffer internally. + - Please never use `dup()`. Use `fcntl(fd, F_DUPFD_CLOEXEC, 3)` instead. For two reasons: first, you want `O_CLOEXEC` set on the new `fd` (see above). Second, `dup()` will happily duplicate your `fd` as 0, 1, 2, |