bind.2: 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-04 12:19:16 +02:00 committed by Michael Kerrisk
parent 78da9b6b29
commit b40e812a64
1 changed files with 3 additions and 3 deletions

View File

@ -293,14 +293,14 @@ main(int argc, char *argv[])
if (sfd == \-1)
handle_error("socket");
memset(&my_addr, 0, sizeof(struct sockaddr_un));
memset(&my_addr, 0, sizeof(my_addr));
/* Clear structure */
my_addr.sun_family = AF_UNIX;
strncpy(my_addr.sun_path, MY_SOCK_PATH,
sizeof(my_addr.sun_path) \- 1);
if (bind(sfd, (struct sockaddr *) &my_addr,
sizeof(struct sockaddr_un)) == \-1)
sizeof(my_addr)) == \-1)
handle_error("bind");
if (listen(sfd, LISTEN_BACKLOG) == \-1)
@ -309,7 +309,7 @@ main(int argc, char *argv[])
/* Now we can accept incoming connections one
at a time using accept(2) */
peer_addr_size = sizeof(struct sockaddr_un);
peer_addr_size = sizeof(peer_addr);
cfd = accept(sfd, (struct sockaddr *) &peer_addr,
&peer_addr_size);
if (cfd == \-1)