Issue #8623: Fix some strict-aliasing warnings. Patch by David Watson.
This commit is contained in:
parent
5b62942074
commit
8b759655d0
@ -436,7 +436,8 @@ dup_socket(SOCKET handle)
|
|||||||
#define SEGMENT_SIZE (32 * 1024 -1)
|
#define SEGMENT_SIZE (32 * 1024 -1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SAS2SA(x) ((struct sockaddr *)(x))
|
/* Convert "sock_addr_t *" to "struct sockaddr *". */
|
||||||
|
#define SAS2SA(x) (&((x)->sa))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constants for getnameinfo()
|
* Constants for getnameinfo()
|
||||||
@ -4148,11 +4149,7 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args)
|
|||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
struct hostent *h;
|
struct hostent *h;
|
||||||
#ifdef ENABLE_IPV6
|
sock_addr_t addr;
|
||||||
struct sockaddr_storage addr;
|
|
||||||
#else
|
|
||||||
struct sockaddr_in addr;
|
|
||||||
#endif
|
|
||||||
struct sockaddr *sa;
|
struct sockaddr *sa;
|
||||||
PyObject *ret = NULL;
|
PyObject *ret = NULL;
|
||||||
#ifdef HAVE_GETHOSTBYNAME_R
|
#ifdef HAVE_GETHOSTBYNAME_R
|
||||||
@ -4171,7 +4168,7 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args)
|
|||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "et:gethostbyname_ex", "idna", &name))
|
if (!PyArg_ParseTuple(args, "et:gethostbyname_ex", "idna", &name))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (setipaddr(name, (struct sockaddr *)&addr, sizeof(addr), AF_INET) < 0)
|
if (setipaddr(name, SAS2SA(&addr), sizeof(addr), AF_INET) < 0)
|
||||||
goto finally;
|
goto finally;
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
#ifdef HAVE_GETHOSTBYNAME_R
|
#ifdef HAVE_GETHOSTBYNAME_R
|
||||||
@ -4196,8 +4193,8 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args)
|
|||||||
addr.ss_family.
|
addr.ss_family.
|
||||||
Therefore, we cast the sockaddr_storage into sockaddr to
|
Therefore, we cast the sockaddr_storage into sockaddr to
|
||||||
access sa_family. */
|
access sa_family. */
|
||||||
sa = (struct sockaddr*)&addr;
|
sa = SAS2SA(&addr);
|
||||||
ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr),
|
ret = gethost_common(h, SAS2SA(&addr), sizeof(addr),
|
||||||
sa->sa_family);
|
sa->sa_family);
|
||||||
#ifdef USE_GETHOSTBYNAME_LOCK
|
#ifdef USE_GETHOSTBYNAME_LOCK
|
||||||
PyThread_release_lock(netdb_lock);
|
PyThread_release_lock(netdb_lock);
|
||||||
@ -4220,12 +4217,8 @@ for a host. The host argument is a string giving a host name or IP number.");
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
socket_gethostbyaddr(PyObject *self, PyObject *args)
|
socket_gethostbyaddr(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_IPV6
|
sock_addr_t addr;
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr *sa = SAS2SA(&addr);
|
||||||
#else
|
|
||||||
struct sockaddr_in addr;
|
|
||||||
#endif
|
|
||||||
struct sockaddr *sa = (struct sockaddr *)&addr;
|
|
||||||
char *ip_num;
|
char *ip_num;
|
||||||
struct hostent *h;
|
struct hostent *h;
|
||||||
PyObject *ret = NULL;
|
PyObject *ret = NULL;
|
||||||
@ -4294,7 +4287,7 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
|
|||||||
h = gethostbyaddr(ap, al, af);
|
h = gethostbyaddr(ap, al, af);
|
||||||
#endif /* HAVE_GETHOSTBYNAME_R */
|
#endif /* HAVE_GETHOSTBYNAME_R */
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), af);
|
ret = gethost_common(h, SAS2SA(&addr), sizeof(addr), af);
|
||||||
#ifdef USE_GETHOSTBYNAME_LOCK
|
#ifdef USE_GETHOSTBYNAME_LOCK
|
||||||
PyThread_release_lock(netdb_lock);
|
PyThread_release_lock(netdb_lock);
|
||||||
#endif
|
#endif
|
||||||
|
@ -115,6 +115,7 @@ typedef int SOCKET_T;
|
|||||||
/* Socket address */
|
/* Socket address */
|
||||||
typedef union sock_addr {
|
typedef union sock_addr {
|
||||||
struct sockaddr_in in;
|
struct sockaddr_in in;
|
||||||
|
struct sockaddr sa;
|
||||||
#ifdef AF_UNIX
|
#ifdef AF_UNIX
|
||||||
struct sockaddr_un un;
|
struct sockaddr_un un;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user