qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-serial: Simplify virtio_serial_load()
@ 2010-05-31 14:19 Markus Armbruster
  2010-06-01  8:22 ` [Qemu-devel] " Amit Shah
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Markus Armbruster @ 2010-05-31 14:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: amit.shah

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] Re: [PATCH] virtio-serial: Simplify virtio_serial_load()
  2010-05-31 14:19 [Qemu-devel] [PATCH] virtio-serial: Simplify virtio_serial_load() Markus Armbruster
@ 2010-06-01  8:22 ` Amit Shah
  2010-06-01 13:23 ` [Qemu-devel] " Alon Levy
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Amit Shah @ 2010-06-01  8:22 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel

On (Mon) May 31 2010 [16:19:43], Markus Armbruster 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(-)

Thanks,

Acked-by: Amit Shah <amit.shah@redhat.com>

		Amit

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] virtio-serial: Simplify virtio_serial_load()
  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
  2010-06-26  5:54 ` [Qemu-devel] " Markus Armbruster
  2010-06-30 18:39 ` [Qemu-devel] " Aurelien Jarno
  3 siblings, 0 replies; 5+ messages in thread
From: Alon Levy @ 2010-06-01 13:23 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: amit shah, qemu-devel


----- "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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] Re: [PATCH] virtio-serial: Simplify virtio_serial_load()
  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 ` [Qemu-devel] " Alon Levy
@ 2010-06-26  5:54 ` Markus Armbruster
  2010-06-30 18:39 ` [Qemu-devel] " Aurelien Jarno
  3 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2010-06-26  5:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: amit.shah

Did this fall through the cracks?

Markus Armbruster <armbru@redhat.com> writes:

> 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);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] virtio-serial: Simplify virtio_serial_load()
  2010-05-31 14:19 [Qemu-devel] [PATCH] virtio-serial: Simplify virtio_serial_load() Markus Armbruster
                   ` (2 preceding siblings ...)
  2010-06-26  5:54 ` [Qemu-devel] " Markus Armbruster
@ 2010-06-30 18:39 ` Aurelien Jarno
  3 siblings, 0 replies; 5+ messages in thread
From: Aurelien Jarno @ 2010-06-30 18:39 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: amit.shah, qemu-devel

On Mon, May 31, 2010 at 04:19:43PM +0200, Markus Armbruster 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(-)

Thanks, applied.

> 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
> 
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-06-30 18:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Qemu-devel] " Alon Levy
2010-06-26  5:54 ` [Qemu-devel] " Markus Armbruster
2010-06-30 18:39 ` [Qemu-devel] " Aurelien Jarno

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).