qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] This patch looks for uses of malloc and convert


From: Stefan Weil
Subject: Re: [Qemu-devel] [PATCH] This patch looks for uses of malloc and convert them to g_malloc
Date: Thu, 29 Sep 2016 19:03:35 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

Am 29.09.2016 um 18:42 schrieb Annapoornima Koppad:
> ---
>  block/iscsi.c                        |  2 +-
>  bsd-user/elfload.c                   | 12 ++++++------
>  disas/libvixl/vixl/a64/disasm-a64.cc |  2 +-
>  disas/m68k.c                         |  2 +-
>  disas/sparc.c                        |  4 ++--
>  hw/audio/fmopl.c                     | 10 +++++-----
>  hw/usb/redirect.c                    |  2 +-
>  include/exec/softmmu-semi.h          |  4 ++--
>  linux-user/elfload.c                 |  2 +-
>  linux-user/syscall.c                 |  2 +-
>  slirp/mbuf.c                         |  4 ++--
>  slirp/sbuf.c                         |  2 +-
>  slirp/socket.c                       |  2 +-
>  slirp/tcp_subr.c                     |  2 +-
>  tests/migration/stress.c             |  4 ++--
>  tests/tcg/cris/check_openpf1.c       |  2 +-
>  tests/tcg/linux-test.c               |  4 ++--
>  tests/tcg/test-mmap.c                |  2 +-
>  thunk.c                              |  2 +-
>  util/compatfd.c                      |  2 +-
>  util/envlist.c                       |  6 +++---
>  21 files changed, 37 insertions(+), 37 deletions(-)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index dff548a..21cb41b 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -963,7 +963,7 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs,
>          return NULL;
>      }
>  
> -    acb->task = malloc(sizeof(struct scsi_task));
> +    acb->task = g_malloc(sizeof(struct scsi_task));
>      if (acb->task == NULL) {
>          error_report("iSCSI: Failed to allocate task for scsi command. %s",
>                       iscsi_get_error(iscsi));
[...]

Hi,

two remarks:

* It is not sufficient to replace malloc by g_malloc.
  You also have to replace free by g_free then.

* If the argument includes sizeof(), then typically
  g_new instead of g_malloc would be a better choice.

Example:

    acb->task = g_new(struct scsi_task, 1);

If you prepare a new patch, it would be good to
split it in smaller parts, for example a single
patch which only handles files under slirp.

Kind regards
Stefan




reply via email to

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