]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
CODING_STYLE: say that inet_ntop() is a no no
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 4 Jun 2022 18:56:29 +0000 (20:56 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 6 Jun 2022 07:52:52 +0000 (09:52 +0200)
docs/CODING_STYLE.md

index 20e7251491b9b42dd1b293ba8f1c3b7a48f0572f..3599db57fb38a00b2351505a596f001c3f8db935 100644 (file)
@@ -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,