From: "Marc-André Lureau" <marcandre.lureau@redhat.com> To: qemu-devel@nongnu.org Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Gerd Hoffmann" <kraxel@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com> Subject: [Qemu-devel] [PATCH 5/5] vhost-user-gpu: initialize msghdr & iov at declaration Date: Wed, 5 Jun 2019 16:58:29 +0200 [thread overview] Message-ID: <20190605145829.7674-6-marcandre.lureau@redhat.com> (raw) In-Reply-To: <20190605145829.7674-1-marcandre.lureau@redhat.com> This should fix uninitialized fields found by coverity CID 1401762. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- contrib/vhost-user-gpu/main.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/contrib/vhost-user-gpu/main.c b/contrib/vhost-user-gpu/main.c index 0ef649ffaa..04b753046f 100644 --- a/contrib/vhost-user-gpu/main.c +++ b/contrib/vhost-user-gpu/main.c @@ -138,22 +138,20 @@ static int vg_sock_fd_write(int sock, const void *buf, ssize_t buflen, int fd) { 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 { struct cmsghdr cmsghdr; char control[CMSG_SPACE(sizeof(int))]; } cmsgu; 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) { msg.msg_control = 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; *((int *)CMSG_DATA(cmsg)) = fd; - } else { - msg.msg_control = NULL; - msg.msg_controllen = 0; } do { -- 2.22.0.rc2.384.g1a9a72ea1d
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com> To: qemu-devel@nongnu.org Cc: "Peter Maydell" <peter.maydell@linaro.org>, "Gerd Hoffmann" <kraxel@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com> Subject: [Qemu-devel] [PULL 05/11] vhost-user-gpu: initialize msghdr & iov at declaration Date: Sun, 16 Jun 2019 17:36:12 -0400 [thread overview] Message-ID: <20190605145829.7674-6-marcandre.lureau@redhat.com> (raw) Message-ID: <20190616213612.sFMeQ_2mdotRPoQ_XMTaa6m-Tmn08HAiqNLr0dau5Xc@z> (raw) In-Reply-To: <20190616213540.20430-1-mst@redhat.com> From: Marc-André Lureau <marcandre.lureau@redhat.com> 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> --- contrib/vhost-user-gpu/main.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/contrib/vhost-user-gpu/main.c b/contrib/vhost-user-gpu/main.c index 0ef649ffaa..04b753046f 100644 --- a/contrib/vhost-user-gpu/main.c +++ b/contrib/vhost-user-gpu/main.c @@ -138,22 +138,20 @@ static int vg_sock_fd_write(int sock, const void *buf, ssize_t buflen, int fd) { 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 { struct cmsghdr cmsghdr; char control[CMSG_SPACE(sizeof(int))]; } cmsgu; 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) { msg.msg_control = 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; *((int *)CMSG_DATA(cmsg)) = fd; - } else { - msg.msg_control = NULL; - msg.msg_controllen = 0; } do { -- MST
next prev parent reply other threads:[~2019-06-05 15:01 UTC|newest] Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-06-05 14:58 [Qemu-devel] [PATCH 0/5] Misc vhost-user fixes Marc-André Lureau 2019-06-05 14:58 ` [Qemu-devel] [PATCH 1/5] vhost-user-gpu: do not send scanout update if no GPU socket Marc-André Lureau 2019-06-16 21:36 ` [Qemu-devel] [PULL 01/11] " Michael S. Tsirkin 2019-06-05 14:58 ` [Qemu-devel] [PATCH 2/5] vhost-user: check unix_listen() return value Marc-André Lureau 2019-06-16 21:36 ` [Qemu-devel] [PULL 02/11] " Michael S. Tsirkin 2019-06-07 8:49 ` [Qemu-devel] [PATCH 2/5] " Peter Maydell 2019-06-26 17:55 ` [Qemu-devel] [PULL 02/11] " Eric Blake 2019-06-26 19:37 ` Marc-André Lureau 2019-06-05 14:58 ` [Qemu-devel] [PATCH 3/5] vhost-user: improve error report Marc-André Lureau 2019-06-16 21:36 ` [Qemu-devel] [PULL 03/11] " Michael S. Tsirkin 2019-06-05 14:58 ` [Qemu-devel] [PATCH 4/5] vhost-user-input: check ioctl(EVIOCGNAME) return value Marc-André Lureau 2019-06-16 21:36 ` [Qemu-devel] [PULL 04/11] " Michael S. Tsirkin 2019-06-07 8:50 ` [Qemu-devel] [PATCH 4/5] " Peter Maydell 2019-06-05 14:58 ` Marc-André Lureau [this message] 2019-06-16 21:36 ` [Qemu-devel] [PULL 05/11] vhost-user-gpu: initialize msghdr & iov at declaration Michael S. Tsirkin 2019-06-07 8:47 ` [Qemu-devel] [PATCH 5/5] " Peter Maydell -- strict thread matches above, loose matches on Subject: below -- 2019-06-16 21:36 [Qemu-devel] [PULL 00/11] virtio, acpi: fixes, cleanups Michael S. Tsirkin 2019-06-16 21:36 ` [Qemu-devel] [PULL 10/11] q35: update DSDT Michael S. Tsirkin 2019-06-16 21:36 ` [Qemu-devel] [PULL 11/11] tests/rebuild-expected-aml.sh: blow out difflist Michael S. Tsirkin 2019-06-17 12:59 ` [Qemu-devel] [PULL 00/11] virtio, acpi: fixes, cleanups Peter Maydell 2019-06-10 1:18 [Qemu-devel] [PATCH v7] hw/acpi: extract acpi_add_rom_blob() Wei Yang 2019-06-16 21:36 ` [Qemu-devel] [PULL 08/11] " Michael S. Tsirkin 2019-06-07 7:34 [Qemu-devel] [PATCH v2] q35: fix mmconfig and PCI0._CRS Gerd Hoffmann 2019-06-16 21:36 ` [Qemu-devel] [PULL 09/11] " Michael S. Tsirkin 2019-06-07 7:49 ` [Qemu-devel] [PATCH v2] " Laszlo Ersek 2019-06-11 8:15 ` Marcel Apfelbaum 2019-06-11 11:37 ` Paolo Bonzini 2019-06-11 12:06 ` Michael S. Tsirkin 2019-06-05 13:12 [Qemu-devel] [PATCH] docs/vhost-user.json: some firmware.json copy leftovers Marc-André Lureau 2019-06-16 21:36 ` [Qemu-devel] [PULL 06/11] " Michael S. Tsirkin 2019-06-14 8:36 ` [Qemu-devel] [PATCH] " Stefan Hajnoczi 2019-06-26 16:24 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier 2019-06-26 16:28 ` Laurent Vivier 2019-06-03 6:15 [Qemu-devel] [PATCH] vhost: fix vhost_log size overflow during migration lihangjing 2019-06-16 21:36 ` [Qemu-devel] [PULL 07/11] " Michael S. Tsirkin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190605145829.7674-6-marcandre.lureau@redhat.com \ --to=marcandre.lureau@redhat.com \ --cc=kraxel@redhat.com \ --cc=mst@redhat.com \ --cc=qemu-devel@nongnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.