emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix use of sockaddr_in


From: Philipp Stephani
Subject: Re: [PATCH] Fix use of sockaddr_in
Date: Sun, 14 May 2017 19:06:26 +0000



Lars Ingebrigtsen <address@hidden> schrieb am So., 14. Mai 2017 um 12:28 Uhr:
Philipp Stephani <address@hidden> writes:

> +                    case AF_INET:
> +                      port = ((struct sockaddr_in6 *) (struct sockaddr *) &sa1)->sin6_port;
> +                      has_port = true;
> +                      break;
> +                    case AF_INET6:
> +                      port = ((struct sockaddr_in *) (struct sockaddr *) &sa1)->sin_port;
> +                      has_port = true;

Aren't these two cases in reverse?  If it's AF_INET6, it's an in6
struct, not the other way around.

Oops, thanks!
 

Not that it matters, since (as Eli said) the sizes of the first elements
in the structs are identical...


I don't know whether we can rely on that (i.e. whether Posix guarantees it) or whether it's an implementation detail.
(This also needs __attribute__((may_alias)), type punning, or memcpy due to aliasing.)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]