Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Feb 2014 18:59:05 +0000
From:      David Chisnall <theraven@FreeBSD.org>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Dimitry Andric <dim@FreeBSD.org>
Subject:   Re: svn commit: r261916 - head/sys/dev/xen/console
Message-ID:  <8C22DE47-60F2-47C0-938D-590324818872@FreeBSD.org>
In-Reply-To: <20140216035823.I2978@besplex.bde.org>
References:  <201402151237.s1FCbRnh000507@svn.freebsd.org> <20140216035823.I2978@besplex.bde.org>

index | next in thread | previous in thread | raw e-mail

On 15 Feb 2014, at 17:02, Bruce Evans <brde@optusnet.com.au> wrote:

> Why?  There are hundreds if not thousands of static inline functions in
> headers, and most of these functions are not always used, so there would
> be [hundreds if not thousands] * [number of #includes] compiler warnings
> if compilers warned about things like this.  They could handle include
> files specially, but shouldn't.

They do, and absolutely should, handle include files separately.  If you have a static inline function in a header that is not used in a specific compilation unit, then that is a little bit of extra work for the compiler as it has to parse it without it being used, but it is not a problem.  It is a safe assumption that it is used by at least one compilation unit and so is not dead code (and even if it isn't yet, it is part of an API, and so removing it would be an error).

In contrast, a static inline function in the main source file for a compilation unit is definitely a bug.  It is obviously dead code.  It is likely that it either should have been removed when all callers were deleted, or should not have been static but accidentally was.  

David



help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8C22DE47-60F2-47C0-938D-590324818872>