qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Ming Lei <ming.lei@canonical.com>
Cc: Fam Zheng <famz@redhat.com>,
	Anthony Liguori <aliguori@amazon.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Markus Armbruster <armbru@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] virtio-scsi-dataplane: fix allocation for 'cmd_vrings'
Date: Mon, 10 Nov 2014 10:21:36 +0100	[thread overview]
Message-ID: <20141110092136.GC4158@noname.str.redhat.com> (raw)
In-Reply-To: <CACVXFVO9auQSFce+YiQEZtoir7KbCVqtSnvkE1JQZzBAXqtnYg@mail.gmail.com>

Am 10.11.2014 um 10:14 hat Ming Lei geschrieben:
> On Mon, Nov 10, 2014 at 4:24 PM, Markus Armbruster <armbru@redhat.com> wrote:
> > Ming Lei <ming.lei@canonical.com> writes:
> >
> >> The size of each element should be sizeof(VirtIOSCSIVring *).
> >>
> >> Signed-off-by: Ming Lei <ming.lei@canonical.com>
> >> ---
> >>  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.

Kevin

  reply	other threads:[~2014-11-10  9:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-09 15:50 [Qemu-devel] [PATCH 0/2] virtio-scsi-dataplane: one fix and one optimization Ming Lei
2014-11-09 15:50 ` [Qemu-devel] [PATCH 1/2] virtio-scsi-dataplane: fix allocation for 'cmd_vrings' Ming Lei
2014-11-10  8:24   ` Markus Armbruster
2014-11-10  9:14     ` Ming Lei
2014-11-10  9:21       ` Kevin Wolf [this message]
2014-11-10  9:49         ` Ming Lei
2014-11-09 15:50 ` [Qemu-devel] [PATCH 2/2] virtio-scsi-dataplane: notify guest as batch Ming Lei
2014-11-10 12:56   ` Paolo Bonzini

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=20141110092136.GC4158@noname.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=ming.lei@canonical.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).