Re: [patch 1/1] consolidate TRUE and FALSE

Andrew Morton
2006-03-16T21:29:33Z

Al Viro <viro@ftp.linux.org.uk> wrote:
>
> On Thu, Mar 16, 2006 at 02:01:28AM -0800, akpm@osdl.org wrote:
> >
> > From: Andrew Morton <akpm@osdl.org>
> >
> > We have no less than 65 implementations of TRUE and FALSE in the tree, so the
> > inevitable happened:
> >
> > In file included from drivers/pci/hotplug/ibmphp_core.c:40:
> > drivers/pci/hotplug/ibmphp.h:409:1: warning: "FALSE" redefined
> > In file included from include/acpi/acpi.h:55,
> > from drivers/pci/hotplug/pci_hotplug.h:187,
> > from drivers/pci/hotplug/ibmphp.h:33,
> > from drivers/pci/hotplug/ibmphp_core.c:40:
> > include/acpi/actypes.h:336:1: warning: this is the location of the previous definition
> >
> > The patch implements TRUE and FALSE in include/linux/kernel.h and removes all
> > the private versions.
>
> NAK. Simply remove those and be done with that. It's bad style and we
> certainly don't need to propagate that lossage.

No, it is not bad style.

It is bad that the C design failed to distinguish between booleans and
scalars. These are quite different concepts and it is a gruesome kludge to
go and use a scalar when a boolean is what was intended.

There are readability (and hence maintainability) advantages in using
boolean types for boolean variables.

Yes, the use of scalars in this manner is an (ancient, old-fashioned) C
idiom. But it is one which was forced on us by shortcomings in the
language. Times change. Just because something is idiomatic doesn't mean
that it is either good or right. If C had had proper boolean support back
in the old days then using scalars as booleans would be frowned upon.

C99 does have boolean support, so the proper thing to do is to start
using it - implement stdbool.h, fix up fallout, start fixing subsystems.
Given that, and as Greg has fixed up this particular build error I'll drop
the patch.

(It's a shame that the compiler doesn't preperly enforce boolean
typechecking, but sparse could do that).