From: Ian Jackson Subject: Re: [PATCH v2 1/3] xen/domain_page: Convert map_domain_page_global() to using mfn_t Date: Mon, 13 Jul 2015 17:56:08 +0100 Message-ID: <21923.60840.497467.16673@mariner.uk.xensource.com> References: <1435838656-9219-1-git-send-email-Ben.Catterall@citrix.com> <559BBF80020000780008D42A@mail.emea.novell.com> <559BA4DE.5000507@citrix.com> <559BCB0C020000780008D499@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZEh1a-0003VX-DK for xen-devel@lists.xenproject.org; Mon, 13 Jul 2015 16:56:14 +0000 In-Reply-To: <559BCB0C020000780008D499@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: keir@xen.org, ian.campbell@citrix.com, Andrew Cooper , tim@xen.org, stefano.stabellini@citrix.com, Ben Catterall , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org Jan Beulich writes ("Re: [Xen-devel] [PATCH v2 1/3] xen/domain_page: Convert map_domain_page_global() to using mfn_t"): > On 07.07.15 at 12:07, wrote: > > Just like free(), these functions are not performing a read-only > > operation on the destination pointer, therefore must not be performed on > > an actual const pointer. > > I disagree - from the caller's persepctive they don't modify the data > being pointed to (that data is simply becoming undefined). An entity > allocating memory, initializing it, and never modifying it again should > be allowed to store the pointer in a variable pointing to a const > modified type, and free/unmap it without needing any casts. I.e. in > fact xfree() and free_xenheap_pages() should have their parameters > constified. Surely xfree() ought to have the same prototype as free() ? free is declared in C99 (7.20.3.2 in my copy of TC2) as: void free(void *ptr); That is, non-const. AFAIAA this is not generally regarded as a bug. I think the same reasoning and conclusion ought to apply to xfree, and other freeing functions. Ian.