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@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Alejandro Colomar 2020-09-03 22:24:12 +02:00 committed by Michael Kerrisk
parent 0ff1c5e28a
commit 012b86a0b6
1 changed files with 4 additions and 4 deletions

View File

@ -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);