From 012b86a0b67fc182c35ab0c8580f47b07a0993ac Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 3 Sep 2020 22:24:12 +0200 Subject: 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 Signed-off-by: Michael Kerrisk --- man7/unix.7 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'man7/unix.7') diff --git a/man7/unix.7 b/man7/unix.7 index 86a35be7b5..30b0e754d4 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); -- cgit 1.2.3-korg