From: Alon Levy <alevy@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: amit shah <amit.shah@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] virtio-serial: Simplify virtio_serial_load()
Date: Tue, 1 Jun 2010 09:23:51 -0400 (EDT) [thread overview]
Message-ID: <1357381040.460321275398631447.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> (raw)
In-Reply-To: <m3ocfwp30g.fsf@blackfin.pond.sub.org>
----- "Markus Armbruster" <armbru@redhat.com> wrote:
> For all i, ports_map[i] is used in and only in the i-th iteration.
> Replace the dynamic array by a scalar variable.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> hw/virtio-serial-bus.c | 12 +++---------
> 1 files changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index 3ce95e8..bcc6d5d 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -492,8 +492,7 @@ static int virtio_serial_load(QEMUFile *f, void
> *opaque, int version_id)
> {
> VirtIOSerial *s = opaque;
> VirtIOSerialPort *port;
> - size_t ports_map_size;
> - uint32_t max_nr_ports, nr_active_ports, *ports_map;
> + uint32_t max_nr_ports, nr_active_ports, ports_map;
> unsigned int i;
>
> if (version_id > 2) {
> @@ -517,22 +516,17 @@ static int virtio_serial_load(QEMUFile *f, void
> *opaque, int version_id)
> return -EINVAL;
> }
>
> - ports_map_size = sizeof(uint32_t) * (max_nr_ports + 31) / 32;
> - ports_map = qemu_malloc(ports_map_size);
> -
> for (i = 0; i < (max_nr_ports + 31) / 32; i++) {
> - qemu_get_be32s(f, &ports_map[i]);
> + qemu_get_be32s(f, &ports_map);
>
> - if (ports_map[i] != s->ports_map[i]) {
> + if (ports_map != s->ports_map[i]) {
> /*
> * Ports active on source and destination don't
> * match. Fail migration.
> */
> - qemu_free(ports_map);
> return -EINVAL;
> }
> }
> - qemu_free(ports_map);
>
> qemu_get_be32s(f, &nr_active_ports);
>
> --
> 1.6.6.1
ACK
next prev parent reply other threads:[~2010-06-01 13:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-31 14:19 [Qemu-devel] [PATCH] virtio-serial: Simplify virtio_serial_load() Markus Armbruster
2010-06-01 8:22 ` [Qemu-devel] " Amit Shah
2010-06-01 13:23 ` Alon Levy [this message]
2010-06-26 5:54 ` Markus Armbruster
2010-06-30 18:39 ` [Qemu-devel] " Aurelien Jarno
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=1357381040.460321275398631447.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com \
--to=alevy@redhat.com \
--cc=amit.shah@redhat.com \
--cc=armbru@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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).