From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDeIZ-0003ux-BJ for qemu-devel@nongnu.org; Wed, 24 May 2017 17:58:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDeIW-0003je-6S for qemu-devel@nongnu.org; Wed, 24 May 2017 17:58:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52686) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDeIV-0003j0-Tt for qemu-devel@nongnu.org; Wed, 24 May 2017 17:58:28 -0400 Date: Thu, 25 May 2017 00:58:22 +0300 From: "Michael S. Tsirkin" Message-ID: <20170525005724-mutt-send-email-mst@kernel.org> References: <20170524090520.321-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170524090520.321-1-maxime.coquelin@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2] vhost-user: pass message as a pointer to process_message_reply() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Maxime Coquelin Cc: zhiyong.yang@intel.com, qemu-devel@nongnu.org, jfreiman@redhat.com, marcandre.lureau@redhat.com On Wed, May 24, 2017 at 11:05:20AM +0200, Maxime Coquelin wrote: > process_message_reply() was recently updated to get full message > content instead of only its request field. > > There is no need to copy all the struct content into the stack, > so just pass its pointer as const. > > Cc: Zhiyong Yang > Fixes: 60cd11024f41 ("hw/virtio: fix vhost user fails to startup when MQ") > Reviewed-by: Jens Freimann > Reviewed-by: Zhiyong Yang > Signed-off-by: Maxime Coquelin Why "Fixes"? It's not a bugfix, is it? Passing a pointer is slightly cleaner but it's not a big deal IMHO. I'll apply but would like to get clarification on this tag. > --- > V2: > - Make msg pointer const (Marc-Andre) > - Apply R-b's > > hw/virtio/vhost-user.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c > index b87a176..dde094a 100644 > --- a/hw/virtio/vhost-user.c > +++ b/hw/virtio/vhost-user.c > @@ -162,11 +162,11 @@ fail: > } > > static int process_message_reply(struct vhost_dev *dev, > - VhostUserMsg msg) > + const VhostUserMsg *msg) > { > VhostUserMsg msg_reply; > > - if ((msg.flags & VHOST_USER_NEED_REPLY_MASK) == 0) { > + if ((msg->flags & VHOST_USER_NEED_REPLY_MASK) == 0) { > return 0; > } > > @@ -174,10 +174,10 @@ static int process_message_reply(struct vhost_dev *dev, > return -1; > } > > - if (msg_reply.request != msg.request) { > + if (msg_reply.request != msg->request) { > error_report("Received unexpected msg type." > "Expected %d received %d", > - msg.request, msg_reply.request); > + msg->request, msg_reply.request); > return -1; > } > > @@ -324,7 +324,7 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev, > } > > if (reply_supported) { > - return process_message_reply(dev, msg); > + return process_message_reply(dev, &msg); > } > > return 0; > @@ -716,7 +716,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu) > > /* If reply_ack supported, slave has to ack specified MTU is valid */ > if (reply_supported) { > - return process_message_reply(dev, msg); > + return process_message_reply(dev, &msg); > } > > return 0; > -- > 2.9.4