From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAzGk-0003H7-VA for qemu-devel@nongnu.org; Mon, 10 Sep 2012 04:23:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TAzGc-0005zS-4M for qemu-devel@nongnu.org; Mon, 10 Sep 2012 04:22:58 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:55752) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAzGb-0005zG-IJ for qemu-devel@nongnu.org; Mon, 10 Sep 2012 04:22:50 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 10 Sep 2012 18:22:16 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8A8MRXW22085884 for ; Mon, 10 Sep 2012 18:22:28 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8A8MRXH019546 for ; Mon, 10 Sep 2012 18:22:27 +1000 Message-ID: <504DA33B.3030903@linux.vnet.ibm.com> Date: Mon, 10 Sep 2012 16:22:19 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1346663926-20188-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1346663926-20188-3-git-send-email-xiawenc@linux.vnet.ibm.com> <5045AB77.1010602@linux.vnet.ibm.com> <5045AFED.2030303@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/6] libqblock public type defines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@gmail.com, qemu-devel@nongnu.org, Paolo Bonzini , eblake@redhat.com changed to const, thanks. > On Tue, Sep 4, 2012 at 7:38 AM, Paolo Bonzini 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