qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [Qemu-devel] [PATCH v2] iscsi: use scsi_create_task()


From: Paolo Bonzini
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2] iscsi: use scsi_create_task()
Date: Tue, 1 Aug 2017 15:03:26 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 28/07/2017 19:52, Marc-André Lureau wrote:
> 
>     Stupid question: what's the benefit?  
> 
> scsi_create/scsi_free is a library API. If they have their own
> allocator, we better use it, or it may easily break, no?

Well, that would be an API breakage, but I see the point.  I think I
would prefer something like

static inline struct scsi_task *iscsi_create_task(...)
{
#if ...
    return scsi_create_task(...)
#else
    /* Older versions of libiscsi have a bug, so include our
     * implementation.
     */
    struct scsi_task *task = g_try_malloc0(sizeof(struct scsi_task));
    if (!task) {
        task;
    }

    memcpy(&task->cdb[0], cdb, cdb_size);
    task->cdb_size   = cdb_size;
    task->xfer_dir   = xfer_dir;
    task->expxferlen = expxferlen;
    return task;
#endif
}

> 
>     Change malloc to g_new0 in the
>     existing code, and we even make it shorter...
> 
> 
> replacing malloc with g_new is the subject of another upcoming series :)
> (https://github.com/elmarco/clang-tools-extra/blob/master/clang-tidy/qemu/UseGnewCheck.cpp)
>  




reply via email to

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