Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Apr 2018 11:39:02 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        John Baldwin <jhb@freebsd.org>
Cc:        arch@freebsd.org
Subject:   Re: LIBC_SCCS
Message-ID:  <20180428110152.Q4737@besplex.bde.org>
In-Reply-To: <1711113.VelFtdTVS7@ralph.baldwin.cx>
References:  <1711113.VelFtdTVS7@ralph.baldwin.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 27 Apr 2018, John Baldwin wrote:

> I suspect no one cares, but for whatever reason our current handling of the
> LIBC_SCCS macro in some of our libraries annoys me.  In theory it seems like
> LIBC_SCCS's purpose is to control whether or not old SCCS IDs from Berkeley
> are included in libc's sources when libc is built.  (Similar to how macros
> control the behavior of __FBSDID().)  However, we use an odd construct in
> the tree.  First, we define LIBC_SCCS by default in the CFLAGS of various
> libraries (libkvm, libutil, libthr, libc, etc.) which in theory would enable
> the IDs, but then we explicitly wrap them in #if 0, e.g.:
>
> #if defined(LIBC_SCCS) && !defined(lint)
> #if 0
> static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93";
> #endif
> #endif /* LIBC_SCCS and not lint */

Most aren't actually wrapped with '#if 0'.  E.g., in libc/*/*.c there are
839 files but only 47 of these have any '#if 0' at all.  SO this can be
fixed without much churn.

I thought there is a problem with the above not actually compiling if
LIBC_SCCS is defined, but WARNS is only 2 for libc and it takes WARNS >= 4
to give -Wwrite-strings.

style(9) says to use '#if 0', but not as above.  It says to put the #if 0
around everything, but only if there is not already a suitable ifdef like
the LIBC_SCCS one.

The above style is apparently from NetBSD.  It is now used a lot on libedit,
with further ugliness and bugs:
- first there is an #if-#else clause with a NetBSD __RCSID() in the #else
   clause, so that the #if 0 selects between the sccsid and the NetBSD id
- __RCSID() may be killed by defining NO__RCSID.  It is a bug that the
   application identifier NO__RCSID affects and system header.  sys/cdefs.h
   is an especially important system header and is one of the few that tries
   to avoid namespace pollution bugs like this.  The default is to keep the
   NetBSD id.
- after this idfef tangle, there is an unconditional __FBSDID() to give the
   FreeBSD id
- __FBSDID() may also be killed by defining either lint or STRIP_FBSDID.
   sys/cdefs.h is actually careless about namespace pollution bugs like this.

> I'd rather that we make LIBC_SCCS actually work by removing the #if 0 (and
> perhaps the lint baggage) but then remove it from the default CFLAGS to
> preserve the existing behavior by default.  Does anyone else care if I do
> this?

I don't mind removing FreeBSD mistakes like the '#if 0'.  Editing to add
const poisoning is hopefully not often needed.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180428110152.Q4737>