Received: from eggs.gnu.org ([2001:4830:134:3::10]:46136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W37Qr-0004DI-0a for qemu-devel@nongnu.org; Tue, 14 Jan 2014 12:05:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W37Qj-0007rX-8b for qemu-devel@nongnu.org; Tue, 14 Jan 2014 12:05:40 -0500 Message-ID: <52D56E5B.9000001@msgid.tls.msk.ru> Date: Tue, 14 Jan 2014 21:05:31 +0400 From: Michael Tokarev MIME-Version: 1.0 References: <20140109095816.409cd2a9@redhat.com> In-Reply-To: <20140109095816.409cd2a9@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio-balloon: don't hardcode config size value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: qemu-trivial , Peter Crosthwaite , qemu-devel , mst@redhat.com 09.01.2014 18:58, Luiz Capitulino wrote: > Use sizeof(strucy virtio_balloon_config) instead. > > --- a/hw/virtio/virtio-balloon.c > +++ b/hw/virtio/virtio-balloon.c > @@ -263,7 +263,7 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data) > config.num_pages = cpu_to_le32(dev->num_pages); > config.actual = cpu_to_le32(dev->actual); > > - memcpy(config_data, &config, 8); > + memcpy(config_data, &config, sizeof(struct virtio_balloon_config)); I'm not sure any of those is better than another. This is a published guest <=> host interface, the config _must_ be 8 bytes long and must contain 2 4-byte words in it. We may use assert(sizeof(struct virtio_balloon_config) == 8) somewhere, but to my taste it is a bit overkill. No? Thanks, /mjt