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: Wenchao Xia
Subject: Re: [Qemu-devel] [PATCH 2/6] libqblock public type defines
Date: Mon, 10 Sep 2012 16:22:19 +0800
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120824 Thunderbird/15.0

changed to const, thanks.

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



--
Best Regards

Wenchao Xia




reply via email to

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