[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for repla
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for replace work |
Date: |
Wed, 12 Mar 2014 06:40:33 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 |
On 03/11/2014 09:10 PM, Chunyan Liu wrote:
>>>>
>>> Could be if changing qemu_opt_get return value type, but just as said
>>> before,
>>> that will affect many codes.
>>
>> Also, changing an existing function that returns 'const char *' into now
>> returning 'char *' will NOT break any callers if the semantics remain
>> unchanged (what WILL break is if the semantics change where the callers
>> must now free the result)
>
>
> Yes, that's the only change, we need to free the result. There are more
> than 200
> places using qemu_opt_get in existing code, we need to checkout the related
> files
> and free the result one by one.
You can still write your helper function so that if 'del' is true, you
strdup, if 'del' is false, you return the in-place memory. You'll have
to cast away const in the helper, but qemu_opt_get can then restore the
const and you don't have to adjust any existing callers, while still
sharing the underlying implementation rather than duplicating code. But
I guess I'll wait for v23 to see what you actually do in response to my
suggestions. If nothing else, please document design decisions in your
commit message (for example, if you choose to duplicate code rather than
share code in a common helper, explain that the duplication is because
one function returns malloc'd memory while the other returns in-place
memory).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
Re: [Qemu-devel] [PATCH v22 03/25] improve some functions in qemu-option.c, Leandro Dorileo, 2014/03/17
[Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for replace work, Chunyan Liu, 2014/03/10
- Re: [Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for replace work, Eric Blake, 2014/03/10
- Re: [Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for replace work, Chunyan Liu, 2014/03/11
- Re: [Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for replace work, Eric Blake, 2014/03/11
- Re: [Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for replace work, Chunyan Liu, 2014/03/11
- Re: [Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for replace work,
Eric Blake <=
- Re: [Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for replace work, Chunyan Liu, 2014/03/13
- Re: [Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for replace work, Chunyan Liu, 2014/03/18
Re: [Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for replace work, Leandro Dorileo, 2014/03/17
[Qemu-devel] [PATCH v22 04/25] improve assertion in qemu_opt_get functions, Chunyan Liu, 2014/03/10
[Qemu-devel] [PATCH v22 06/25] add convert functions between QEMUOptionParameter to QemuOpts, Chunyan Liu, 2014/03/10
[Qemu-devel] [PATCH v22 08/25] cow.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/03/10