From owner-svn-src-projects@FreeBSD.ORG Wed Mar 13 22:26:26 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4DEBEA7F; Wed, 13 Mar 2013 22:26:26 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 199562EC; Wed, 13 Mar 2013 22:26:26 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 7ECFF3592DF; Wed, 13 Mar 2013 23:26:24 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 5DC742848C; Wed, 13 Mar 2013 23:26:24 +0100 (CET) Date: Wed, 13 Mar 2013 23:26:24 +0100 From: Jilles Tjoelker To: "Cherry G. Mathew" Subject: Re: svn commit: r248199 - projects/amd64_xen_pv/sys/amd64/xen Message-ID: <20130313222624.GC61432@stack.nl> References: <201303121233.r2CCXp7F075011@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201303121233.r2CCXp7F075011@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-projects@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2013 22:26:26 -0000 On Tue, Mar 12, 2013 at 12:33:51PM +0000, Cherry G. Mathew wrote: > Author: cherry > Date: Tue Mar 12 12:33:50 2013 > New Revision: 248199 > URL: http://svnweb.freebsd.org/changeset/base/248199 > Log: > Modify the mmu_map_hold_va() to indicate if it had to allocate backing pages. > 'const'ify memrchr() to reflect its level of access to datatypes. > Approved by: gibbs (implicit) > Modified: > projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c > projects/amd64_xen_pv/sys/amd64/xen/mmu_map.h > Modified: projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c > ============================================================================== > --- projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c Tue Mar 12 12:23:47 2013 (r248198) > +++ projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c Tue Mar 12 12:33:50 2013 (r248199) > [snip] > /*$FreeBSD: head/lib/libc/string/memrchr.c 178051 2008-04-10 00:12:44Z delphij $*/ > @@ -381,16 +388,19 @@ mmu_map_hold_va(struct pmap *pm, void *a > * Reverse memchr() > * Find the last occurrence of 'c' in the buffer 's' of size 'n'. > */ > -static void * > + > +static const void * memrchr(const void *, int, size_t); > + > +static const void * > memrchr(const void *s, int c, size_t n) > { > const unsigned char *cp; > > if (n != 0) { > - cp = (unsigned char *)s + n; > + cp = (const unsigned char *)s + n; > do { > if (*(--cp) == (unsigned char)c) > - return((void *)cp); > + return((const void *)cp); > } while (--n != 0); > } > return(NULL); Perhaps add a comment here why the definition has been tightened. The real memrchr() can work on const and non-const strings but must cast away const in its definition somehow and relies on the programmer to keep the const when a const pointer was passed. This modified version respects the limitations of const better and does not allow modifying a non-const string through its result. If that is all you need, it reduces warnings/ugliness. -- Jilles Tjoelker