Home GnuPG

socket: Use union for sockaddr access.

Description

socket: Use union for sockaddr access.

* src/assuan-socket.c (socks5_connect, use_socks): Use union
to access, instead of using cast to the pointer.

In some machine like 32-bit ARM, alignment requirement of struct
sockaddr and struct sockaddr_in (or struct sockaddr_in6) is different.

Although it is completely valid to use the value of the address by
cast here, because the object should be allocated by struct
sockaddr_in or struct sockaddr_in6 to be referred by struct
sockaddr *. But compiler doesn't assume such a usage, thus, emits
warnings.

The API with struct sockaddr * is a bit difficult thing. I examined
GNU C library for the implementation of the connect function, it uses
transparent union, the GCC feature. It would be too much, if we do
same thing here.

  • Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>

Details

Provenance
gniibeAuthored on Nov 8 2018, 10:21 AM
Parents
rA50ed4f7d5b68: build: Update gpg-error.m4 and libassuan.m4.
Branches
Unknown
Tags
Unknown