From: Wen Congyang <wency@cn.fujitsu.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PULL 10/19] vfio/pci: Foundation for new quirk structure
Date: Thu, 24 Sep 2015 11:27:59 +0800 [thread overview]
Message-ID: <56036DBF.7090204@cn.fujitsu.com> (raw)
In-Reply-To: <1443064948.23936.528.camel@redhat.com>
On 09/24/2015 11:22 AM, Alex Williamson wrote:
> On Thu, 2015-09-24 at 10:54 +0800, Wen Congyang wrote:
>> On 09/24/2015 04:23 AM, Alex Williamson wrote:
>>> @@ -275,12 +276,15 @@ static void vfio_vga_probe_ati_3c3_quirk(VFIOPCIDevice *vdev)
>>> }
>>>
>>> quirk = g_malloc0(sizeof(*quirk));
>>> - quirk->vdev = vdev;
>>> + legacy = quirk->data = g_malloc0(sizeof(*legacy));
>>> + quirk->mem = legacy->mem = g_malloc0_n(sizeof(MemoryRegion), 1);
>>
>> Why do you use g_malloc0_n() here? It is introduced in glib 2.24, but we only require glib 2.22.
>
> Because I saw it, I guess in scripts/coverity-model.c, and used it. In
> this particular instance it seems irrelevant, but VFIOQuirk.mem points
> to an array of MemoryRegions, other users here have more than one array
> entry and I chose to use the same allocator throughout for consistency.
> What's the preferred helper here, simply calloc()? Thanks,
Yes, there is g_malloc0_n() in scripts/coverity-model.c. But it still breaks
building. calloc()? I guess we don't use it directly in qemu.
g_malloc0_n ()
gpointer
g_malloc0_n (gsize n_blocks,
gsize n_block_bytes);
This function is similar to g_malloc0(), allocating (n_blocks * n_block_bytes ) bytes, but care is taken to detect possible overflow during multiplication.
So I think we can use g_malloc0(sizeof(MemoryRegion) * n).
Thanks
Wen Congyang
>
> Alex
>
> .
>
next prev parent reply other threads:[~2015-09-24 3:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-23 20:23 [Qemu-devel] [PULL 00/19] VFIO updates Alex Williamson
2015-09-23 20:23 ` [Qemu-devel] [PULL 01/19] vfio/pci: Cleanup RTL8168 quirk and tracing Alex Williamson
2015-09-23 20:23 ` [Qemu-devel] [PULL 02/19] vfio/pci: Cleanup vfio_early_setup_msix() error path Alex Williamson
2015-09-23 20:23 ` [Qemu-devel] [PULL 03/19] vfio/pci: Rename INTx functions for easier tracing Alex Williamson
2015-09-23 20:23 ` [Qemu-devel] [PULL 04/19] vfio/pci: Rename MSI/X " Alex Williamson
2015-09-23 20:23 ` [Qemu-devel] [PULL 05/19] vfio/pci: Make interrupt bypass runtime configurable Alex Williamson
2015-09-23 20:23 ` [Qemu-devel] [PULL 06/19] vfio: Change polarity of our no-mmap option Alex Williamson
2015-09-23 20:23 ` [Qemu-devel] [PULL 07/19] vfio/pci: Extract PCI structures to a separate header Alex Williamson
2015-09-23 20:23 ` [Qemu-devel] [PULL 08/19] vfio/pci: Split quirks to a separate file Alex Williamson
2015-09-23 20:23 ` [Qemu-devel] [PULL 09/19] vfio/pci: Cleanup ROM blacklist quirk Alex Williamson
2015-09-23 20:23 ` [Qemu-devel] [PULL 10/19] vfio/pci: Foundation for new quirk structure Alex Williamson
2015-09-24 2:54 ` Wen Congyang
2015-09-24 3:22 ` Alex Williamson
2015-09-24 3:27 ` Wen Congyang [this message]
2015-09-23 20:24 ` [Qemu-devel] [PULL 11/19] vfio/pci: Cleanup ATI 0x3c3 quirk Alex Williamson
2015-09-23 20:24 ` [Qemu-devel] [PULL 12/19] vfio/pci: Cleanup Nvidia 0x3d0 quirk Alex Williamson
2015-09-23 20:24 ` [Qemu-devel] [PULL 13/19] vfio/pci: Rework RTL8168 quirk Alex Williamson
2015-09-23 20:24 ` [Qemu-devel] [PULL 14/19] vfio/pci: Config window quirks Alex Williamson
2015-09-23 20:24 ` [Qemu-devel] [PULL 15/19] vfio/pci: Config mirror quirk Alex Williamson
2015-09-23 20:24 ` [Qemu-devel] [PULL 16/19] vfio/pci: Remove old config window and mirror quirks Alex Williamson
2015-09-23 20:24 ` [Qemu-devel] [PULL 17/19] vfio/pci: Move AMD device specific reset to quirks Alex Williamson
2015-09-23 20:24 ` [Qemu-devel] [PULL 18/19] vfio/pci: Cache vendor and device ID Alex Williamson
2015-09-23 20:24 ` [Qemu-devel] [PULL 19/19] vfio/pci: Add emulated PCI IDs Alex Williamson
2015-09-24 0:02 ` [Qemu-devel] [PULL 00/19] VFIO updates Peter Maydell
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=56036DBF.7090204@cn.fujitsu.com \
--to=wency@cn.fujitsu.com \
--cc=alex.williamson@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).