mirror of https://gitee.com/openkylin/qemu.git
vhost-user-gpu: initialize msghdr & iov at declaration
This should fix uninitialized fields found by coverity CID 1401762. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190605145829.7674-6-marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
be32fd9ee1
commit
c715130a64
|
@ -138,22 +138,20 @@ static int
|
||||||
vg_sock_fd_write(int sock, const void *buf, ssize_t buflen, int fd)
|
vg_sock_fd_write(int sock, const void *buf, ssize_t buflen, int fd)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
struct msghdr msg;
|
struct iovec iov = {
|
||||||
struct iovec iov;
|
.iov_base = (void *)buf,
|
||||||
|
.iov_len = buflen,
|
||||||
|
};
|
||||||
|
struct msghdr msg = {
|
||||||
|
.msg_iov = &iov,
|
||||||
|
.msg_iovlen = 1,
|
||||||
|
};
|
||||||
union {
|
union {
|
||||||
struct cmsghdr cmsghdr;
|
struct cmsghdr cmsghdr;
|
||||||
char control[CMSG_SPACE(sizeof(int))];
|
char control[CMSG_SPACE(sizeof(int))];
|
||||||
} cmsgu;
|
} cmsgu;
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
|
|
||||||
iov.iov_base = (void *)buf;
|
|
||||||
iov.iov_len = buflen;
|
|
||||||
|
|
||||||
msg.msg_name = NULL;
|
|
||||||
msg.msg_namelen = 0;
|
|
||||||
msg.msg_iov = &iov;
|
|
||||||
msg.msg_iovlen = 1;
|
|
||||||
|
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
msg.msg_control = cmsgu.control;
|
msg.msg_control = cmsgu.control;
|
||||||
msg.msg_controllen = sizeof(cmsgu.control);
|
msg.msg_controllen = sizeof(cmsgu.control);
|
||||||
|
@ -164,9 +162,6 @@ vg_sock_fd_write(int sock, const void *buf, ssize_t buflen, int fd)
|
||||||
cmsg->cmsg_type = SCM_RIGHTS;
|
cmsg->cmsg_type = SCM_RIGHTS;
|
||||||
|
|
||||||
*((int *)CMSG_DATA(cmsg)) = fd;
|
*((int *)CMSG_DATA(cmsg)) = fd;
|
||||||
} else {
|
|
||||||
msg.msg_control = NULL;
|
|
||||||
msg.msg_controllen = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
Loading…
Reference in New Issue