sock_sendmsg/sock_recvmsg: Use {0} to 0-initialize aggregate types with

automatic storage class.
This commit is contained in:
Charles-François Natali 2011-08-24 21:40:53 +02:00
parent b09f25e9a3
commit e9e95ae93d
1 changed files with 2 additions and 7 deletions

View File

@ -2780,8 +2780,7 @@ sock_recvmsg_guts(PySocketSockObject *s, struct iovec *iov, int iovlen,
int timeout; int timeout;
sock_addr_t addrbuf; sock_addr_t addrbuf;
socklen_t addrbuflen; socklen_t addrbuflen;
static const struct msghdr msg_blank; struct msghdr msg = {0};
struct msghdr msg;
PyObject *cmsg_list = NULL, *retval = NULL; PyObject *cmsg_list = NULL, *retval = NULL;
void *controlbuf = NULL; void *controlbuf = NULL;
struct cmsghdr *cmsgh; struct cmsghdr *cmsgh;
@ -2815,7 +2814,6 @@ sock_recvmsg_guts(PySocketSockObject *s, struct iovec *iov, int iovlen,
BEGIN_SELECT_LOOP(s) BEGIN_SELECT_LOOP(s)
Py_BEGIN_ALLOW_THREADS; Py_BEGIN_ALLOW_THREADS;
msg = msg_blank; /* Set all members to 0 or NULL */
msg.msg_name = SAS2SA(&addrbuf); msg.msg_name = SAS2SA(&addrbuf);
msg.msg_namelen = addrbuflen; msg.msg_namelen = addrbuflen;
msg.msg_iov = iov; msg.msg_iov = iov;
@ -3292,8 +3290,7 @@ sock_sendmsg(PySocketSockObject *s, PyObject *args)
Py_buffer *databufs = NULL; Py_buffer *databufs = NULL;
struct iovec *iovs = NULL; struct iovec *iovs = NULL;
sock_addr_t addrbuf; sock_addr_t addrbuf;
static const struct msghdr msg_blank; struct msghdr msg = {0};
struct msghdr msg;
struct cmsginfo { struct cmsginfo {
int level; int level;
int type; int type;
@ -3310,8 +3307,6 @@ sock_sendmsg(PySocketSockObject *s, PyObject *args)
&data_arg, &cmsg_arg, &flags, &addr_arg)) &data_arg, &cmsg_arg, &flags, &addr_arg))
return NULL; return NULL;
msg = msg_blank; /* Set all members to 0 or NULL */
/* Parse destination address. */ /* Parse destination address. */
if (addr_arg != NULL && addr_arg != Py_None) { if (addr_arg != NULL && addr_arg != Py_None) {
if (!getsockaddrarg(s, addr_arg, SAS2SA(&addrbuf), &addrlen)) if (!getsockaddrarg(s, addr_arg, SAS2SA(&addrbuf), &addrlen))