From owner-freebsd-bugs@FreeBSD.ORG Sun Mar 16 13:17:17 2008 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 740A9106566C for ; Sun, 16 Mar 2008 13:17:17 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id 6793A8FC23 for ; Sun, 16 Mar 2008 13:17:17 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id E064146C62; Sun, 16 Mar 2008 09:17:16 -0400 (EDT) Date: Sun, 16 Mar 2008 13:17:16 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Mark Linimon In-Reply-To: <200803160750.m2G7o21t025830@freefall.freebsd.org> Message-ID: <20080316131652.E83063@fledge.watson.org> References: <200803160750.m2G7o21t025830@freefall.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-bugs@FreeBSD.org Subject: Re: bin/71613: [PATCH] traceroute(8): cleanup of the usr.sbin/traceroute6 code X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Mar 2008 13:17:17 -0000 Mark, Normally I expect to see these e-mails coming from bugmaster as opposed to you... :-) Robert N M Watson Computer Laboratory University of Cambridge On Sun, 16 Mar 2008, Mark Linimon wrote: > The following reply was made to PR bin/71613; it has been noted by GNATS. > > From: linimon@lonesome.com (Mark Linimon) > To: bug-followup@FreeBSD.org > Cc: > Subject: Re: bin/71613: [PATCH] traceroute(8): cleanup of the usr.sbin/traceroute6 code > Date: Sun, 16 Mar 2008 02:42:13 -0500 > > ----- Forwarded message from Bruce Evans ----- > > From: Bruce Evans > To: Dan Lukes > Cc: freebsd-bugs@freebsd.org > > __COPYRIGHT() in reduces this problem by concatenating > __LINE__. It could also concatenate a file name (but not __FILE__, since > that is probably not an identifier). > > > It seems we need 'static'. Unfortunately, static unused variable can > >be optimized out. > > > > Adding 'const' and/or __used clear the warning, but doesn't prevent > >"optimized-out" problem. The 'const' shall be used because the string is > >constant. We can use __used, but it has limited portability. > > > > We still have the problem the variable may be optimized out. > > __used prevents this. > > > The 'volatile' is way to tell an ANSI C compiler "this variable may > >be modified via mechanism you don't know about it" - it mean "count it as > >used" and "don't optimize it". Note, the 'const' and 'static' are ANSI C > >keywords also, so compiler knowing 'static' shall handle 'volatile' as well. > > volatile doesn't prevent the variable being optimized out for gcc-4.2. > This makes some sense -- volatile sort of means "use it carefully", but > when it is not used no care with it is needed. > > > Conclusion (for the case we can't guarantee the unique name of > >variable): > >static MUST > >const SHALL > >__used SHALL > >volatile MUST > > > >So my recomentation is: > >0: static volatile const char __used copyright[]=... > > > >because of __unused the sys/cdefs.h must be included first. > > I prefer 'static char const __used copyright[]'. Not sure where __used > belongs. > > >The other way to fix it is > >1: the sys/copyright.h way - e.g. plain char variable - but the variable > >must be unique across the sources which sound not so easy for me > > Not too bad -- there is supposed to be only one copyright[] per executable. > > >2. the __COPYRIGHT way, but > >2a: IDSTRING must be corrected first > >2b: the '\n' must be removed from the source. > > > >sys/cdefs.h must be included first. > > > > In my opinion the preference shall be 2a then 0 then 1 or 2b but > > it's not strict. The commiter shall select the best way. > > 2b is no good. > > __COPYRIGHT() of course allows putting all the unportabilities in one > place and changing the easily. It's just too ugly for me. Everything in > should have gone away with __P(()). > > Bruce > > ----- End forwarded message ----- > _______________________________________________ > freebsd-bugs@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-bugs > To unsubscribe, send any mail to "freebsd-bugs-unsubscribe@freebsd.org" >