[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] Convert uses of malloc to g_malloc
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] Convert uses of malloc to g_malloc |
Date: |
Thu, 29 Sep 2016 20:07:43 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 |
On 29/09/2016 19:10, Daniel P. Berrange wrote:
>> >
>> > - 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));
> For every malloc you convert to g_malloc, you must also
> convert the corresponding 'free' to 'g_free'. This seems
> missing throughout your patch.
Also realloc -> g_realloc when that applies. Finally, checks for
allocation errors should be removed after g_malloc (or g_new).
Paolo