>From 63fa45f7c45c49df2eeab0735342de9304507e46 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar <colomar.6.4.3@xxxxxxxxx> Date: Thu, 3 Sep 2020 22:24:12 +0200 Subject: [PATCH 34/34] unix.7: Use sizeof consistently Use ``sizeof`` consistently through all the examples in the following way: - Use the name of the variable instead of its type as argument for ``sizeof``. Rationale: https://www.kernel.org/doc/html/v5.8/process/coding-style.html#allocating-memory Signed-off-by: Alejandro Colomar <colomar.6.4.3@xxxxxxxxx> --- man7/unix.7 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/man7/unix.7 b/man7/unix.7 index 86a35be7b..30b0e754d 100644 --- a/man7/unix.7 +++ b/man7/unix.7 @@ -948,7 +948,7 @@ main(int argc, char *argv[]) * the structure. */ - memset(&name, 0, sizeof(struct sockaddr_un)); + memset(&name, 0, sizeof(name)); /* Bind socket to socket name. */ @@ -956,7 +956,7 @@ main(int argc, char *argv[]) strncpy(name.sun_path, SOCKET_NAME, sizeof(name.sun_path) \- 1); ret = bind(connection_socket, (const struct sockaddr *) &name, - sizeof(struct sockaddr_un)); + sizeof(name)); if (ret == \-1) { perror("bind"); exit(EXIT_FAILURE); @@ -1082,7 +1082,7 @@ main(int argc, char *argv[]) * the structure. */ - memset(&addr, 0, sizeof(struct sockaddr_un)); + memset(&addr, 0, sizeof(addr)); /* Connect socket to socket address */ @@ -1090,7 +1090,7 @@ main(int argc, char *argv[]) strncpy(addr.sun_path, SOCKET_NAME, sizeof(addr.sun_path) \- 1); ret = connect(data_socket, (const struct sockaddr *) &addr, - sizeof(struct sockaddr_un)); + sizeof(addr)); if (ret == \-1) { fprintf(stderr, "The server is down.\en"); exit(EXIT_FAILURE); -- 2.28.0