qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/6] libqblock public type defines


From: Blue Swirl
Subject: Re: [Qemu-devel] [PATCH 2/6] libqblock public type defines
Date: Tue, 4 Sep 2012 19:22:09 +0000

On Tue, Sep 4, 2012 at 7:38 AM, Paolo Bonzini <address@hidden> wrote:
> Il 04/09/2012 09:19, Wenchao Xia ha scritto:
>>>>
>>>> +struct QBlockOption_prot_file {
>>>
>>> QBlockOptionProtFile
>>>
>>>> +    char *filename;
>>>
>>> 'const'
>>>
>>   There is a problem, this member would be used in information
>> retrieving, so it will be set to a pointer to a string allocated
>> at runtime, and later be freed. I am not sure if const fits for this
>> situation, let me check.
>
> No, const would add useless complication.  In C++ it is different
> because you have constructors.

Using 'const' would mean that it's also possible for the client to use
constant strings without casts which remove 'const' qualifier. This
will be important if the client code is compiled with -Wcast-qual.
QEMU does not use it ATM, but we also don't control what compiler
flags are used for the client.

'const' also tells the developer that the library will not modify or
free the string, so there's documentation value.

>
> Paolo



reply via email to

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