qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] virtio-scsi-dataplane: fix allocation for '


From: Ming Lei
Subject: Re: [Qemu-devel] [PATCH 1/2] virtio-scsi-dataplane: fix allocation for 'cmd_vrings'
Date: Mon, 10 Nov 2014 17:49:38 +0800

On Mon, Nov 10, 2014 at 5:21 PM, Kevin Wolf <address@hidden> wrote:
> Am 10.11.2014 um 10:14 hat Ming Lei geschrieben:
>> On Mon, Nov 10, 2014 at 4:24 PM, Markus Armbruster <address@hidden> wrote:
>> > Ming Lei <address@hidden> writes:
>> >
>> >> The size of each element should be sizeof(VirtIOSCSIVring *).
>> >>
>> >> Signed-off-by: Ming Lei <address@hidden>
>> >> ---
>> >>  hw/scsi/virtio-scsi-dataplane.c |    2 +-
>> >>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >>
>> >> diff --git a/hw/scsi/virtio-scsi-dataplane.c 
>> >> b/hw/scsi/virtio-scsi-dataplane.c
>> >> index 855439e..8a7cd9f 100644
>> >> --- a/hw/scsi/virtio-scsi-dataplane.c
>> >> +++ b/hw/scsi/virtio-scsi-dataplane.c
>> >> @@ -239,7 +239,7 @@ void virtio_scsi_dataplane_start(VirtIOSCSI *s)
>> >>      if (!s->event_vring) {
>> >>          goto fail_vrings;
>> >>      }
>> >> -    s->cmd_vrings = g_malloc0(sizeof(VirtIOSCSIVring) * 
>> >> vs->conf.num_queues);
>> >> +    s->cmd_vrings = g_malloc0(sizeof(VirtIOSCSIVring *) * 
>> >> vs->conf.num_queues);
>> >>      for (i = 0; i < vs->conf.num_queues; i++) {
>> >>          s->cmd_vrings[i] =
>> >>              virtio_scsi_vring_init(s, vs->cmd_vqs[i],
>> >
>> > Please use something like
>> >
>> >     s->cmd_vrings = g_new0(VirtIOSCSIVring *, vs->conf.num_queues);
>> >
>> > This one crept in since I cleaned up g_malloc() use globally:
>>
>> Your idea is good, but this one is a fix patch, and I
>> think the g_new() conversion should be done in another
>> patch since the two changes are different logically.
>
> It's not really unrelated: g_new() would have caught the incorrect type
> and made it a compiler error. So changing to g_new() in a patch fixing
> such a bug is actually a logical conclusion and makes it more obvious
> that your patch is correct.

Fair enough, will post v1 with g_new() conversion.

Thanks,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]