From owner-cvs-all Thu Sep 6 9:21:44 2001 Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id E638A37B401; Thu, 6 Sep 2001 09:21:36 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id CAA10601; Fri, 7 Sep 2001 02:19:54 +1000 Date: Fri, 7 Sep 2001 02:19:18 +1000 (EST) From: Bruce Evans X-X-Sender: To: Mark Murray Cc: Maxim Sobolev , Mark Murray , , Subject: Re: cvs commit: src/usr.bin/su Makefile su.c In-Reply-To: <200109051017.f85AH2k99078@grimreaper.grondar.za> Message-ID: <20010907015343.K32058-100000@alphplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 5 Sep 2001, Mark Murray wrote: > > > markm 2001/09/04 10:10:57 PDT > > > > > >[...] > > > > > > This solves the problem (in my own mind) of how a "const char *" _ever_ > > > actually gets a value in a WARNS=2 world. > > > > const char *foo = "bar"; ??? > > Right :-). > > Now how do you get (variable) stuff into a 'const char *'? /* Initialize `foo' in its declaration would be a style bug. */ const char *foo; ... foo = variable_stuff(); /* What's the problem? */ > For example - a function is not allowed to modify its arguments, so > they are const, but the stuff being passed in is by no means constant. > That one is easy - you can pass a 'foo *' into a 'const foo *'. Now, Initializing the "const char *" is easy because it is essentially the same as this. > how do you build up a 'const foo *' in such a way that you can, but > nobody else can? This question is sort of backwards too. You want to get const non-built-up stuff into a plain "char *". > Like perl's un-tainting, C needs a formal un-consting, and I guess > this is it. It's just a cast to non-const in ISO C. gcc -Wcast-qual emits warnings that some would consider spurious. But you asked for them by setting WARNS=2. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message