From: Andrew Morton <[email protected]>
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.
The patch also kills off a few private implementations of NULL.
Note that the patch also removes TRUE, FALSE and NULL from
include/acpi/actypes.h. If this breaks ACPi on non-linux builds I'd suggest
that these things should be implemented in an OS-specific ACPI header, not in
a generic one. Because this OS now provides TRUE and FALSE and NULL.
Various places are doing things like
typedef {
FALSE,
TRUE
} my_fave_name_for_a_bool;
These are converted to
typedef int my_fave_name_for_a_bool;
Cc: "Brown, Len" <[email protected]>
Cc: Anton Altaparmakov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---
Documentation/mtrr.txt | 5 -----
arch/alpha/kernel/smc37c669.c | 7 -------
arch/arm/nwfpe/milieu.h | 9 ---------
arch/arm26/nwfpe/milieu.h | 9 ---------
arch/i386/kernel/cpu/mtrr/mtrr.h | 5 -----
arch/mips/ite-boards/generic/lpc.c | 8 --------
arch/parisc/math-emu/float.h | 2 --
arch/ppc/4xx_io/serial_sicc.c | 7 -------
arch/ppc/boot/common/misc-common.c | 7 ++-----
arch/ppc/boot/simple/rw4/stb.h | 11 -----------
drivers/block/z2ram.c | 3 ---
drivers/char/ftape/compressor/lzrw3.h | 3 ---
drivers/char/mwave/smapi.h | 2 --
drivers/char/rio/rio.h | 7 -------
drivers/char/rio/sam.h | 7 -------
drivers/input/joystick/iforce/iforce.h | 3 ---
drivers/isdn/hardware/eicon/platform.h | 12 ------------
drivers/isdn/hisax/hfc_usb.h | 4 ----
drivers/media/radio/radio-gemtek-pci.c | 8 --------
drivers/media/video/cx88/cx88.h | 6 ------
drivers/media/video/saa5246a.h | 5 -----
drivers/media/video/saa5249.c | 5 -----
drivers/media/video/saa7134/saa7134.h | 6 ------
drivers/net/3c505.c | 15 ---------------
drivers/net/8139cp.c | 5 -----
drivers/net/dm9000.c | 3 ---
drivers/net/e1000/e1000_osdep.h | 7 +------
drivers/net/ixgb/ixgb_osdep.h | 7 +------
drivers/net/oaknet.c | 8 --------
drivers/net/s2io.h | 5 -----
drivers/net/skfp/h/targetos.h | 3 ---
drivers/net/tlan.h | 3 ---
drivers/net/tokenring/ibmtr.c | 3 ---
drivers/net/tulip/de4x5.h | 3 ---
drivers/net/wireless/strip.c | 2 --
drivers/net/wireless/wavelan_cs.h | 3 ---
drivers/pci/hotplug/ibmphp.h | 2 --
drivers/scsi/advansys.c | 7 -------
drivers/scsi/aic7xxx/aic79xx.h | 7 -------
drivers/scsi/aic7xxx/aic7xxx.h | 7 -------
drivers/scsi/aic7xxx/aicasm/aicasm.h | 8 --------
drivers/scsi/aic7xxx_old.c | 6 ------
drivers/scsi/dpti.h | 6 ------
drivers/scsi/eata_generic.h | 7 -------
drivers/scsi/gdth.h | 7 -------
drivers/scsi/nsp32.h | 6 ------
drivers/scsi/scsi.h | 10 ----------
drivers/scsi/u14-34f.c | 2 --
drivers/scsi/ultrastor.c | 3 ---
drivers/telephony/ixj.h | 3 ---
drivers/usb/serial/io_edgeport.h | 6 ------
drivers/usb/serial/whiteheat.h | 5 -----
drivers/video/cirrusfb.c | 9 ---------
drivers/video/riva/riva_hw.h | 10 ----------
drivers/video/sis/vgatypes.h | 8 --------
fs/cifs/cifsfs.h | 8 --------
fs/cifs/cifsglob.h | 8 --------
fs/cifs/smbencrypt.c | 7 -------
fs/devfs/base.c | 5 -----
fs/jfs/jfs_types.h | 2 --
fs/ntfs/types.h | 5 +----
fs/partitions/ldm.c | 5 +----
include/asm-ppc/gt64260.h | 8 --------
include/linux/agp_backend.h | 8 --------
include/linux/agpgart.h | 8 --------
include/linux/kernel.h | 7 +++++++
include/linux/ps2esdi.h | 3 ---
include/linux/synclink.h | 2 --
include/net/irda/irda.h | 8 --------
sound/oss/aedsp16.c | 6 ------
sound/oss/os.h | 3 ---
71 files changed, 13 insertions(+), 407 deletions(-)
diff -puN arch/alpha/kernel/smc37c669.c~consolidate-true-and-false arch/alpha/kernel/smc37c669.c
--- devel/arch/alpha/kernel/smc37c669.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/arch/alpha/kernel/smc37c669.c 2006-03-16 02:01:02.000000000 -0800
@@ -947,13 +947,6 @@ void SMC37c669_display_device_info(
#include "cp$src:platform.h"
#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
#define wb( _x_, _y_ ) outb( _y_, (unsigned int)((unsigned long)_x_) )
#define rb( _x_ ) inb( (unsigned int)((unsigned long)_x_) )
diff -puN arch/arm26/nwfpe/milieu.h~consolidate-true-and-false arch/arm26/nwfpe/milieu.h
--- devel/arch/arm26/nwfpe/milieu.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/arch/arm26/nwfpe/milieu.h 2006-03-16 02:01:02.000000000 -0800
@@ -35,14 +35,3 @@ Include common integer types and flags.
-------------------------------------------------------------------------------
*/
#include "ARM-gcc.h"
-
-/*
--------------------------------------------------------------------------------
-Symbolic Boolean literals.
--------------------------------------------------------------------------------
-*/
-enum {
- FALSE = 0,
- TRUE = 1
-};
-
diff -puN arch/arm/nwfpe/milieu.h~consolidate-true-and-false arch/arm/nwfpe/milieu.h
--- devel/arch/arm/nwfpe/milieu.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/arch/arm/nwfpe/milieu.h 2006-03-16 02:01:02.000000000 -0800
@@ -35,14 +35,3 @@ Include common integer types and flags.
-------------------------------------------------------------------------------
*/
#include "ARM-gcc.h"
-
-/*
--------------------------------------------------------------------------------
-Symbolic Boolean literals.
--------------------------------------------------------------------------------
-*/
-enum {
- FALSE = 0,
- TRUE = 1
-};
-
diff -puN arch/i386/kernel/cpu/mtrr/mtrr.h~consolidate-true-and-false arch/i386/kernel/cpu/mtrr/mtrr.h
--- devel/arch/i386/kernel/cpu/mtrr/mtrr.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/arch/i386/kernel/cpu/mtrr/mtrr.h 2006-03-16 02:01:02.000000000 -0800
@@ -2,11 +2,6 @@
* local mtrr defines.
*/
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
#define MTRRcap_MSR 0x0fe
#define MTRRdefType_MSR 0x2ff
diff -puN arch/mips/ite-boards/generic/lpc.c~consolidate-true-and-false arch/mips/ite-boards/generic/lpc.c
--- devel/arch/mips/ite-boards/generic/lpc.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/arch/mips/ite-boards/generic/lpc.c 2006-03-16 02:01:02.000000000 -0800
@@ -33,14 +33,6 @@
#include <asm/it8712.h>
#include <asm/it8172/it8172.h>
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
void LPCEnterMBPnP(void)
{
int i;
diff -puN arch/parisc/math-emu/float.h~consolidate-true-and-false arch/parisc/math-emu/float.h
--- devel/arch/parisc/math-emu/float.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/arch/parisc/math-emu/float.h 2006-03-16 02:01:02.000000000 -0800
@@ -392,8 +392,6 @@ typedef struct dblwd dbl_unsigned;
#define QUAD_P 113
/* Boolean Values etc. */
-#define FALSE 0
-#define TRUE (!FALSE)
#define NOT !
#define XOR ^
diff -puN arch/ppc/4xx_io/serial_sicc.c~consolidate-true-and-false arch/ppc/4xx_io/serial_sicc.c
--- devel/arch/ppc/4xx_io/serial_sicc.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/arch/ppc/4xx_io/serial_sicc.c 2006-03-16 02:01:02.000000000 -0800
@@ -185,13 +185,6 @@
#define SERIAL_SICC_MINOR 1
#define SERIAL_SICC_NR 1
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
/*
* Things needed by tty driver
*/
diff -puN arch/ppc/boot/common/misc-common.c~consolidate-true-and-false arch/ppc/boot/common/misc-common.c
--- devel/arch/ppc/boot/common/misc-common.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/arch/ppc/boot/common/misc-common.c 2006-03-16 02:01:02.000000000 -0800
@@ -287,9 +287,6 @@ puthex(unsigned long val)
puts(buf);
}
-#define FALSE 0
-#define TRUE 1
-
void
_printk(char const *fmt, ...)
{
@@ -323,11 +320,11 @@ _vprintk(void(*putc)(const char), const
}
if (c == '0')
{
- zero_fill = TRUE;
+ zero_fill = 1;
c = *fmt0++;
} else
{
- zero_fill = FALSE;
+ zero_fill = 0;
}
while (is_digit(c))
{
diff -puN arch/ppc/boot/simple/rw4/stb.h~consolidate-true-and-false arch/ppc/boot/simple/rw4/stb.h
--- devel/arch/ppc/boot/simple/rw4/stb.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/arch/ppc/boot/simple/rw4/stb.h 2006-03-16 02:01:02.000000000 -0800
@@ -225,15 +225,4 @@
#define STB_SDRAM_BASE_ADDRESS 0xA0000000
#endif
-/*----------------------------------------------------------------------------+
-| Other common defines.
-+----------------------------------------------------------------------------*/
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
#endif /* _stb_h_ */
diff -puN Documentation/mtrr.txt~consolidate-true-and-false Documentation/mtrr.txt
--- devel/Documentation/mtrr.txt~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/Documentation/mtrr.txt 2006-03-16 02:01:02.000000000 -0800
@@ -147,11 +147,8 @@ Reading MTRRs from a C program using ioc
#define MTRR_NEED_STRINGS
#include <asm/mtrr.h>
-#define TRUE 1
-#define FALSE 0
#define ERRSTRING strerror (errno)
-
int main ()
{
int fd;
@@ -235,8 +232,6 @@ Creating MTRRs from a C programme using
#define MTRR_NEED_STRINGS
#include <asm/mtrr.h>
-#define TRUE 1
-#define FALSE 0
#define ERRSTRING strerror (errno)
diff -puN drivers/block/z2ram.c~consolidate-true-and-false drivers/block/z2ram.c
--- devel/drivers/block/z2ram.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/block/z2ram.c 2006-03-16 02:01:02.000000000 -0800
@@ -44,9 +44,6 @@
extern int m68k_realnum_memory;
extern struct mem_info m68k_memory[NUM_MEMINFO];
-#define TRUE (1)
-#define FALSE (0)
-
#define Z2MINOR_COMBINED (0)
#define Z2MINOR_Z2ONLY (1)
#define Z2MINOR_CHIPONLY (2)
diff -puN drivers/char/ftape/compressor/lzrw3.h~consolidate-true-and-false drivers/char/ftape/compressor/lzrw3.h
--- devel/drivers/char/ftape/compressor/lzrw3.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/char/ftape/compressor/lzrw3.h 2006-03-16 02:01:02.000000000 -0800
@@ -168,9 +168,6 @@
#define FOPEN_BINARY_WRITE not used /* Mode string for binary writing. */
#define FOPEN_TEXT_APPEND not used /* Mode string for text appending. */
#define REAL not used /* USed for floating point stuff. */
- #ifndef TRUE
- #define TRUE 1
- #endif
#endif
#define DONE_PORT /* Don't do all this again. */
diff -puN drivers/char/mwave/smapi.h~consolidate-true-and-false drivers/char/mwave/smapi.h
--- devel/drivers/char/mwave/smapi.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/char/mwave/smapi.h 2006-03-16 02:01:02.000000000 -0800
@@ -49,8 +49,6 @@
#ifndef _LINUX_SMAPI_H
#define _LINUX_SMAPI_H
-#define TRUE 1
-#define FALSE 0
#define BOOLEAN int
typedef struct {
diff -puN drivers/char/rio/rio.h~consolidate-true-and-false drivers/char/rio/rio.h
--- devel/drivers/char/rio/rio.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/char/rio/rio.h 2006-03-16 02:01:02.000000000 -0800
@@ -221,13 +221,6 @@ typedef struct DbInf {
char Name[8];
} DbInf;
-#ifndef TRUE
-#define TRUE (1==1)
-#endif
-#ifndef FALSE
-#define FALSE (!TRUE)
-#endif
-
#define CSUM(pkt_ptr) (((ushort *)(pkt_ptr))[0] + ((ushort *)(pkt_ptr))[1] + \
((ushort *)(pkt_ptr))[2] + ((ushort *)(pkt_ptr))[3] + \
((ushort *)(pkt_ptr))[4] + ((ushort *)(pkt_ptr))[5] + \
diff -puN drivers/char/rio/sam.h~consolidate-true-and-false drivers/char/rio/sam.h
--- devel/drivers/char/rio/sam.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/char/rio/sam.h 2006-03-16 02:01:02.000000000 -0800
@@ -45,13 +45,6 @@
#define NUM_FREE_LIST_UNITS 500
-#ifndef FALSE
-#define FALSE (short) 0x00
-#endif
-#ifndef TRUE
-#define TRUE (short) !FALSE
-#endif
-
#define TX TRUE
#define RX FALSE
diff -puN drivers/input/joystick/iforce/iforce.h~consolidate-true-and-false drivers/input/joystick/iforce/iforce.h
--- devel/drivers/input/joystick/iforce/iforce.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/input/joystick/iforce/iforce.h 2006-03-16 02:01:02.000000000 -0800
@@ -51,9 +51,6 @@
#define IFORCE_232 1
#define IFORCE_USB 2
-#define FALSE 0
-#define TRUE 1
-
#define FF_EFFECTS_MAX 32
/* Each force feedback effect is made of one core effect, which can be
diff -puN drivers/isdn/hardware/eicon/platform.h~consolidate-true-and-false drivers/isdn/hardware/eicon/platform.h
--- devel/drivers/isdn/hardware/eicon/platform.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/isdn/hardware/eicon/platform.h 2006-03-16 02:01:02.000000000 -0800
@@ -72,18 +72,6 @@
#define qword u64
#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#ifndef MIN
#define MIN(a,b) ((a)>(b) ? (b) : (a))
#endif
diff -puN drivers/isdn/hisax/hfc_usb.h~consolidate-true-and-false drivers/isdn/hisax/hfc_usb.h
--- devel/drivers/isdn/hisax/hfc_usb.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/isdn/hisax/hfc_usb.h 2006-03-16 02:01:02.000000000 -0800
@@ -12,10 +12,6 @@
#define VERBOSE_USB_DEBUG
-#define TRUE 1
-#define FALSE 0
-
-
/***********/
/* defines */
/***********/
diff -puN drivers/media/radio/radio-gemtek-pci.c~consolidate-true-and-false drivers/media/radio/radio-gemtek-pci.c
--- devel/drivers/media/radio/radio-gemtek-pci.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/media/radio/radio-gemtek-pci.c 2006-03-16 02:01:02.000000000 -0800
@@ -65,14 +65,6 @@
#define GEMTEK_PCI_RANGE_HIGH (108*16000)
#endif
-#ifndef TRUE
-#define TRUE (1)
-#endif
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
struct gemtek_pci_card {
struct video_device *videodev;
diff -puN drivers/media/video/cx88/cx88.h~consolidate-true-and-false drivers/media/video/cx88/cx88.h
--- devel/drivers/media/video/cx88/cx88.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/media/video/cx88/cx88.h 2006-03-16 02:01:02.000000000 -0800
@@ -37,12 +37,6 @@
#include <linux/version.h>
#define CX88_VERSION_CODE KERNEL_VERSION(0,0,5)
-#ifndef TRUE
-# define TRUE (1==1)
-#endif
-#ifndef FALSE
-# define FALSE (1==0)
-#endif
#define UNSET (-1U)
#define CX88_MAXBOARDS 8
diff -puN drivers/media/video/saa5246a.h~consolidate-true-and-false drivers/media/video/saa5246a.h
--- devel/drivers/media/video/saa5246a.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/media/video/saa5246a.h 2006-03-16 02:01:02.000000000 -0800
@@ -53,11 +53,6 @@
((p_req)->start <= POS_HEADER_END && \
(p_req)->end >= POS_HEADER_START)
-#ifndef FALSE
-#define FALSE 0
-#define TRUE 1
-#endif
-
/*****************************************************************************/
/* Mode register numbers of the SAA5246A */
/*****************************************************************************/
diff -puN drivers/media/video/saa5249.c~consolidate-true-and-false drivers/media/video/saa5249.c
--- devel/drivers/media/video/saa5249.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/media/video/saa5249.c 2006-03-16 02:01:02.000000000 -0800
@@ -121,11 +121,6 @@ struct saa5249_device
/* General defines and debugging support */
-#ifndef FALSE
-#define FALSE 0
-#define TRUE 1
-#endif
-
#define RESCHED do { cond_resched(); } while(0)
static struct video_device saa_template; /* Declared near bottom */
diff -puN drivers/media/video/saa7134/saa7134.h~consolidate-true-and-false drivers/media/video/saa7134/saa7134.h
--- devel/drivers/media/video/saa7134/saa7134.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/media/video/saa7134/saa7134.h 2006-03-16 02:01:02.000000000 -0800
@@ -42,12 +42,6 @@
#include <sound/pcm.h>
#include <media/video-buf-dvb.h>
-#ifndef TRUE
-# define TRUE (1==1)
-#endif
-#ifndef FALSE
-# define FALSE (1==0)
-#endif
#define UNSET (-1U)
/* ----------------------------------------------------------- */
diff -puN drivers/net/3c505.c~consolidate-true-and-false drivers/net/3c505.c
--- devel/drivers/net/3c505.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/3c505.c 2006-03-16 02:01:02.000000000 -0800
@@ -169,21 +169,6 @@ static int elp_debug;
/*****************************************************************
*
- * useful macros
- *
- *****************************************************************/
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-
-/*****************************************************************
- *
* List of I/O-addresses we try to auto-sense
* Last element MUST BE 0!
*****************************************************************/
diff -puN drivers/net/8139cp.c~consolidate-true-and-false drivers/net/8139cp.c
--- devel/drivers/net/8139cp.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/8139cp.c 2006-03-16 02:01:02.000000000 -0800
@@ -108,11 +108,6 @@ MODULE_PARM_DESC (multicast_filter_limit
#define PFX DRV_NAME ": "
-#ifndef TRUE
-#define FALSE 0
-#define TRUE (!FALSE)
-#endif
-
#define CP_DEF_MSG_ENABLE (NETIF_MSG_DRV | \
NETIF_MSG_PROBE | \
NETIF_MSG_LINK)
diff -puN drivers/net/dm9000.c~consolidate-true-and-false drivers/net/dm9000.c
--- devel/drivers/net/dm9000.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/dm9000.c 2006-03-16 02:01:02.000000000 -0800
@@ -77,9 +77,6 @@
#define DM9000_PHY 0x40 /* PHY address 0x01 */
-#define TRUE 1
-#define FALSE 0
-
#define CARDNAME "dm9000"
#define PFX CARDNAME ": "
diff -puN drivers/net/e1000/e1000_osdep.h~consolidate-true-and-false drivers/net/e1000/e1000_osdep.h
--- devel/drivers/net/e1000/e1000_osdep.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/e1000/e1000_osdep.h 2006-03-16 02:01:02.000000000 -0800
@@ -60,12 +60,7 @@
#define PCI_COMMAND_REGISTER PCI_COMMAND
#define CMD_MEM_WRT_INVALIDATE PCI_COMMAND_INVALIDATE
-typedef enum {
-#undef FALSE
- FALSE = 0,
-#undef TRUE
- TRUE = 1
-} boolean_t;
+typedef int boolean_t;
#define MSGOUT(S, A, B) printk(KERN_DEBUG S "\n", A, B)
diff -puN drivers/net/ixgb/ixgb_osdep.h~consolidate-true-and-false drivers/net/ixgb/ixgb_osdep.h
--- devel/drivers/net/ixgb/ixgb_osdep.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/ixgb/ixgb_osdep.h 2006-03-16 02:01:02.000000000 -0800
@@ -52,12 +52,7 @@
#define PCI_COMMAND_REGISTER PCI_COMMAND
#define CMD_MEM_WRT_INVALIDATE PCI_COMMAND_INVALIDATE
-typedef enum {
-#undef FALSE
- FALSE = 0,
-#undef TRUE
- TRUE = 1
-} boolean_t;
+typedef int boolean_t;
#undef ASSERT
#define ASSERT(x) if(!(x)) BUG()
diff -puN drivers/net/oaknet.c~consolidate-true-and-false drivers/net/oaknet.c
--- devel/drivers/net/oaknet.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/oaknet.c 2006-03-16 02:01:02.000000000 -0800
@@ -29,14 +29,6 @@
/* Preprocessor Defines */
-#if !defined(TRUE) || TRUE != 1
-#define TRUE 1
-#endif
-
-#if !defined(FALSE) || FALSE != 0
-#define FALSE 0
-#endif
-
#define OAKNET_START_PG 0x20 /* First page of TX buffer */
#define OAKNET_STOP_PG 0x40 /* Last pagge +1 of RX ring */
diff -puN drivers/net/s2io.h~consolidate-true-and-false drivers/net/s2io.h
--- devel/drivers/net/s2io.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/s2io.h 2006-03-16 02:01:02.000000000 -0800
@@ -22,11 +22,6 @@
#define BOOL int
#endif
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
#undef SUCCESS
#define SUCCESS 0
#define FAILURE -1
diff -puN drivers/net/skfp/h/targetos.h~consolidate-true-and-false drivers/net/skfp/h/targetos.h
--- devel/drivers/net/skfp/h/targetos.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/skfp/h/targetos.h 2006-03-16 02:01:02.000000000 -0800
@@ -60,9 +60,6 @@
#include "h/hwmtm.h"
-#define TRUE 1
-#define FALSE 0
-
// HWM Definitions
// -----------------------
#define FDDI_TRACE(string, arg1, arg2, arg3) // Performance analysis.
diff -puN drivers/net/tlan.h~consolidate-true-and-false drivers/net/tlan.h
--- devel/drivers/net/tlan.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/tlan.h 2006-03-16 02:01:02.000000000 -0800
@@ -33,9 +33,6 @@
*
****************************************************************/
-#define FALSE 0
-#define TRUE 1
-
#define TLAN_MIN_FRAME_SIZE 64
#define TLAN_MAX_FRAME_SIZE 1600
diff -puN drivers/net/tokenring/ibmtr.c~consolidate-true-and-false drivers/net/tokenring/ibmtr.c
--- devel/drivers/net/tokenring/ibmtr.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/tokenring/ibmtr.c 2006-03-16 02:01:02.000000000 -0800
@@ -116,9 +116,6 @@ in the event that chatty debug messages
#define ENABLE_PAGING 1
#endif
-#define FALSE 0
-#define TRUE (!FALSE)
-
/* changes the output format of driver initialization */
#define TR_VERBOSE 0
diff -puN drivers/net/tulip/de4x5.h~consolidate-true-and-false drivers/net/tulip/de4x5.h
--- devel/drivers/net/tulip/de4x5.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/tulip/de4x5.h 2006-03-16 02:01:02.000000000 -0800
@@ -896,10 +896,7 @@
** Booleans
*/
#define NO 0
-#define FALSE 0
-
#define YES ~0
-#define TRUE ~0
/*
** Adapter state
diff -puN drivers/net/wireless/strip.c~consolidate-true-and-false drivers/net/wireless/strip.c
--- devel/drivers/net/wireless/strip.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/wireless/strip.c 2006-03-16 02:01:02.000000000 -0800
@@ -178,8 +178,6 @@ typedef struct {
MetricomNode node[NODE_TABLE_SIZE];
} MetricomNodeTable;
-enum { FALSE = 0, TRUE = 1 };
-
/*
* Holds the radio's firmware version.
*/
diff -puN drivers/net/wireless/wavelan_cs.h~consolidate-true-and-false drivers/net/wireless/wavelan_cs.h
--- devel/drivers/net/wireless/wavelan_cs.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/net/wireless/wavelan_cs.h 2006-03-16 02:01:02.000000000 -0800
@@ -151,9 +151,6 @@ static const int fixed_bands[] = { 915e6
#define RX_SIZE (TX_BASE-RX_BASE) /* Size of receive area */
#define RX_SIZE_SHIFT 6 /* Bits to shift in stop register */
-#define TRUE 1
-#define FALSE 0
-
#define MOD_ENAL 1
#define MOD_PROM 2
diff -puN drivers/pci/hotplug/ibmphp.h~consolidate-true-and-false drivers/pci/hotplug/ibmphp.h
--- devel/drivers/pci/hotplug/ibmphp.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/pci/hotplug/ibmphp.h 2006-03-16 02:01:02.000000000 -0800
@@ -406,8 +406,6 @@ extern void ibmphp_hpc_stop_poll_thread
//----------------------------------------------------------------------------
// HPC return codes
//----------------------------------------------------------------------------
-#define FALSE 0x00
-#define TRUE 0x01
#define HPC_ERROR 0xFF
//-----------------------------------------------------------------------------
diff -puN drivers/scsi/advansys.c~consolidate-true-and-false drivers/scsi/advansys.c
--- devel/drivers/scsi/advansys.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/advansys.c 2006-03-16 02:01:02.000000000 -0800
@@ -865,13 +865,6 @@
typedef unsigned char uchar;
-#ifndef TRUE
-#define TRUE (1)
-#endif
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
#define EOF (-1)
#define ERR (-1)
#define UW_ERR (uint)(0xFFFF)
diff -puN drivers/scsi/aic7xxx/aic79xx.h~consolidate-true-and-false drivers/scsi/aic7xxx/aic79xx.h
--- devel/drivers/scsi/aic7xxx/aic79xx.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/aic7xxx/aic79xx.h 2006-03-16 02:01:02.000000000 -0800
@@ -61,13 +61,6 @@ struct scb_platform_data;
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
#define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))
#define ALL_CHANNELS '\0'
diff -puN drivers/scsi/aic7xxx/aic7xxx.h~consolidate-true-and-false drivers/scsi/aic7xxx/aic7xxx.h
--- devel/drivers/scsi/aic7xxx/aic7xxx.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/aic7xxx/aic7xxx.h 2006-03-16 02:01:02.000000000 -0800
@@ -62,13 +62,6 @@ struct seeprom_descriptor;
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
#define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))
#define ALL_CHANNELS '\0'
diff -puN drivers/scsi/aic7xxx/aicasm/aicasm.h~consolidate-true-and-false drivers/scsi/aic7xxx/aicasm/aicasm.h
--- devel/drivers/scsi/aic7xxx/aicasm/aicasm.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/aic7xxx/aicasm/aicasm.h 2006-03-16 02:01:02.000000000 -0800
@@ -48,14 +48,6 @@
#include <sys/queue.h>
#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
typedef struct path_entry {
char *directory;
int quoted_includes_only;
diff -puN drivers/scsi/aic7xxx_old.c~consolidate-true-and-false drivers/scsi/aic7xxx_old.c
--- devel/drivers/scsi/aic7xxx_old.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/aic7xxx_old.c 2006-03-16 02:01:02.000000000 -0800
@@ -258,12 +258,6 @@
#define ALL_LUNS -1
#define MAX_TARGETS 16
#define MAX_LUNS 8
-#ifndef TRUE
-# define TRUE 1
-#endif
-#ifndef FALSE
-# define FALSE 0
-#endif
#if defined(__powerpc__) || defined(__i386__) || defined(__x86_64__)
# define MMAPIO
diff -puN drivers/scsi/dpti.h~consolidate-true-and-false drivers/scsi/dpti.h
--- devel/drivers/scsi/dpti.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/dpti.h 2006-03-16 02:01:02.000000000 -0800
@@ -158,12 +158,6 @@ static int adpt_device_reset(struct scsi
#define I2O_SCSI_DSC_BUS_BUSY 0x3F00
#define I2O_SCSI_DSC_QUEUE_FROZEN 0x4000
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
#define HBA_FLAGS_INSTALLED_B 0x00000001 // Adapter Was Installed
#define HBA_FLAGS_BLINKLED_B 0x00000002 // Adapter In Blink LED State
#define HBA_FLAGS_IN_RESET 0x00000040 /* in reset */
diff -puN drivers/scsi/eata_generic.h~consolidate-true-and-false drivers/scsi/eata_generic.h
--- devel/drivers/scsi/eata_generic.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/eata_generic.h 2006-03-16 02:01:02.000000000 -0800
@@ -18,13 +18,6 @@
* Misc. definitions *
*********************************************/
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
#define R_LIMIT 0x20000
#define MAXISA 4
diff -puN drivers/scsi/gdth.h~consolidate-true-and-false drivers/scsi/gdth.h
--- devel/drivers/scsi/gdth.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/gdth.h 2006-03-16 02:01:02.000000000 -0800
@@ -16,13 +16,6 @@
#include <linux/version.h>
#include <linux/types.h>
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
/* defines, macros */
/* driver version */
diff -puN drivers/scsi/nsp32.h~consolidate-true-and-false drivers/scsi/nsp32.h
--- devel/drivers/scsi/nsp32.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/nsp32.h 2006-03-16 02:01:02.000000000 -0800
@@ -76,12 +76,6 @@ typedef u16 u16_le;
/*
* BASIC Definitions
*/
-#ifndef TRUE
-# define TRUE 1
-#endif
-#ifndef FALSE
-# define FALSE 0
-#endif
#define ASSERT 1
#define NEGATE 0
diff -puN drivers/scsi/scsi.h~consolidate-true-and-false drivers/scsi/scsi.h
--- devel/drivers/scsi/scsi.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/scsi.h 2006-03-16 02:01:02.000000000 -0800
@@ -29,16 +29,6 @@
#include <scsi/scsi_tcq.h>
#include <scsi/scsi.h>
-/*
- * Some defs, in case these are not defined elsewhere.
- */
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
struct Scsi_Host;
struct scsi_cmnd;
struct scsi_device;
diff -puN drivers/scsi/u14-34f.c~consolidate-true-and-false drivers/scsi/u14-34f.c
--- devel/drivers/scsi/u14-34f.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/u14-34f.c 2006-03-16 02:01:02.000000000 -0800
@@ -502,8 +502,6 @@ static struct scsi_host_template driver_
#define MAX_TAGGED_CMD_PER_LUN (MAX_MAILBOXES - MAX_CMD_PER_LUN)
#define SKIP ULONG_MAX
-#define FALSE 0
-#define TRUE 1
#define FREE 0
#define IN_USE 1
#define LOCKED 2
diff -puN drivers/scsi/ultrastor.c~consolidate-true-and-false drivers/scsi/ultrastor.c
--- devel/drivers/scsi/ultrastor.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/scsi/ultrastor.c 2006-03-16 02:01:02.000000000 -0800
@@ -148,9 +148,6 @@
#include <scsi/scsi_host.h>
#include "ultrastor.h"
-#define FALSE 0
-#define TRUE 1
-
#ifndef ULTRASTOR_DEBUG
#define ULTRASTOR_DEBUG (UD_ABORT|UD_CSIR|UD_RESET)
#endif
diff -puN drivers/telephony/ixj.h~consolidate-true-and-false drivers/telephony/ixj.h
--- devel/drivers/telephony/ixj.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/telephony/ixj.h 2006-03-16 02:01:02.000000000 -0800
@@ -54,9 +54,6 @@ typedef __u8 BOOL;
#define IXJMAX 16
#endif
-#define TRUE 1
-#define FALSE 0
-
/******************************************************************************
*
* This structure when unioned with the structures below makes simple byte
diff -puN drivers/usb/serial/io_edgeport.h~consolidate-true-and-false drivers/usb/serial/io_edgeport.h
--- devel/drivers/usb/serial/io_edgeport.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/usb/serial/io_edgeport.h 2006-03-16 02:01:02.000000000 -0800
@@ -19,12 +19,6 @@
#define MAX_RS232_PORTS 8 /* Max # of RS-232 ports per device */
/* typedefs that the insideout headers need */
-#ifndef TRUE
- #define TRUE (1)
-#endif
-#ifndef FALSE
- #define FALSE (0)
-#endif
#ifndef LOW8
#define LOW8(a) ((unsigned char)(a & 0xff))
#endif
diff -puN drivers/usb/serial/whiteheat.h~consolidate-true-and-false drivers/usb/serial/whiteheat.h
--- devel/drivers/usb/serial/whiteheat.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/usb/serial/whiteheat.h 2006-03-16 02:01:02.000000000 -0800
@@ -19,11 +19,6 @@
#ifndef __LINUX_USB_SERIAL_WHITEHEAT_H
#define __LINUX_USB_SERIAL_WHITEHEAT_H
-
-#define FALSE 0
-#define TRUE 1
-
-
/* WhiteHEAT commands */
#define WHITEHEAT_OPEN 1 /* open the port */
#define WHITEHEAT_CLOSE 2 /* close the port */
diff -puN drivers/video/cirrusfb.c~consolidate-true-and-false drivers/video/cirrusfb.c
--- devel/drivers/video/cirrusfb.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/video/cirrusfb.c 2006-03-16 02:01:02.000000000 -0800
@@ -100,15 +100,6 @@
#define assert(expr)
#endif
-#ifdef TRUE
-#undef TRUE
-#endif
-#ifdef FALSE
-#undef FALSE
-#endif
-#define TRUE 1
-#define FALSE 0
-
#define MB_ (1024*1024)
#define KB_ (1024)
diff -puN drivers/video/riva/riva_hw.h~consolidate-true-and-false drivers/video/riva/riva_hw.h
--- devel/drivers/video/riva/riva_hw.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/video/riva/riva_hw.h 2006-03-16 02:01:02.000000000 -0800
@@ -53,16 +53,6 @@
typedef int Bool;
#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef NULL
-#define NULL 0
-#endif
-
/*
* Typedefs to force certain sized values.
*/
diff -puN drivers/video/sis/vgatypes.h~consolidate-true-and-false drivers/video/sis/vgatypes.h
--- devel/drivers/video/sis/vgatypes.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/drivers/video/sis/vgatypes.h 2006-03-16 02:01:02.000000000 -0800
@@ -57,14 +57,6 @@
#include <linux/version.h>
#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
#ifndef BOOLEAN
typedef unsigned int BOOLEAN;
#endif
diff -puN fs/cifs/cifsfs.h~consolidate-true-and-false fs/cifs/cifsfs.h
--- devel/fs/cifs/cifsfs.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/fs/cifs/cifsfs.h 2006-03-16 02:01:02.000000000 -0800
@@ -24,14 +24,6 @@
#define ROOT_I 2
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
extern struct address_space_operations cifs_addr_ops;
/* Functions related to super block operations */
diff -puN fs/cifs/cifsglob.h~consolidate-true-and-false fs/cifs/cifsglob.h
--- devel/fs/cifs/cifsglob.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/fs/cifs/cifsglob.h 2006-03-16 02:01:02.000000000 -0800
@@ -55,14 +55,6 @@
#include "cifspdu.h"
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
#ifndef XATTR_DOS_ATTRIB
#define XATTR_DOS_ATTRIB "user.DOSATTRIB"
#endif
diff -puN fs/cifs/smbencrypt.c~consolidate-true-and-false fs/cifs/smbencrypt.c
--- devel/fs/cifs/smbencrypt.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/fs/cifs/smbencrypt.c 2006-03-16 02:01:02.000000000 -0800
@@ -34,13 +34,6 @@
#include "cifs_debug.h"
#include "cifsencrypt.h"
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
/* following came from the other byteorder.h to avoid include conflicts */
#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
diff -puN fs/devfs/base.c~consolidate-true-and-false fs/devfs/base.c
--- devel/fs/devfs/base.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/fs/devfs/base.c 2006-03-16 02:01:02.000000000 -0800
@@ -697,11 +697,6 @@
#define POISON_PTR ( *(void **) poison_array )
#define MAGIC_VALUE 0x327db823
-#ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-#endif
-
#define MODE_DIR (S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO)
#define DEBUG_NONE 0x0000000
diff -puN fs/jfs/jfs_types.h~consolidate-true-and-false fs/jfs/jfs_types.h
--- devel/fs/jfs/jfs_types.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/fs/jfs/jfs_types.h 2006-03-16 02:01:02.000000000 -0800
@@ -58,8 +58,6 @@ struct timestruc_t {
#define ONES 0xffffffffu /* all bit on */
typedef int boolean_t;
-#define TRUE 1
-#define FALSE 0
/*
* logical xd (lxd)
diff -puN fs/ntfs/types.h~consolidate-true-and-false fs/ntfs/types.h
--- devel/fs/ntfs/types.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/fs/ntfs/types.h 2006-03-16 02:01:02.000000000 -0800
@@ -61,10 +61,7 @@ typedef sle64 leLSN;
typedef s64 USN;
typedef sle64 leUSN;
-typedef enum {
- FALSE = 0,
- TRUE = 1
-} BOOL;
+typedef int BOOL;
typedef enum {
CASE_SENSITIVE = 0,
diff -puN fs/partitions/ldm.c~consolidate-true-and-false fs/partitions/ldm.c
--- devel/fs/partitions/ldm.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/fs/partitions/ldm.c 2006-03-16 02:01:02.000000000 -0800
@@ -30,10 +30,7 @@
#include "check.h"
#include "msdos.h"
-typedef enum {
- FALSE = 0,
- TRUE = 1
-} BOOL;
+typedef int BOOL;
/**
* ldm_debug/info/error/crit - Output an error message
diff -puN include/asm-ppc/gt64260.h~consolidate-true-and-false include/asm-ppc/gt64260.h
--- devel/include/asm-ppc/gt64260.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/include/asm-ppc/gt64260.h 2006-03-16 02:01:02.000000000 -0800
@@ -32,14 +32,6 @@ extern u32 gt64260_irq_base; /*
extern u32 gt64260_revision;
extern u8 gt64260_pci_exclude_bridge;
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
/* IRQs defined by the 64260 */
#define GT64260_IRQ_MPSC0 40
#define GT64260_IRQ_MPSC1 42
diff -puN include/linux/agp_backend.h~consolidate-true-and-false include/linux/agp_backend.h
--- devel/include/linux/agp_backend.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/include/linux/agp_backend.h 2006-03-16 02:01:02.000000000 -0800
@@ -32,14 +32,6 @@
#ifdef __KERNEL__
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
enum chipset_type {
NOT_SUPPORTED,
SUPPORTED,
diff -puN include/linux/agpgart.h~consolidate-true-and-false include/linux/agpgart.h
--- devel/include/linux/agpgart.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/include/linux/agpgart.h 2006-03-16 02:01:02.000000000 -0800
@@ -43,14 +43,6 @@
#define AGP_DEVICE "/dev/agpgart"
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
#ifndef __KERNEL__
#include <linux/types.h>
#include <asm/types.h>
diff -puN include/linux/kernel.h~consolidate-true-and-false include/linux/kernel.h
--- devel/include/linux/kernel.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/include/linux/kernel.h 2006-03-16 02:01:02.000000000 -0800
@@ -18,6 +18,13 @@
extern const char linux_banner[];
+/*
+ * Give these a funny-looking definition to improve the chances of them
+ * clashing with other definitions of TRUE and FALSE, causing a cpp error
+ */
+#define TRUE ((1))
+#define FALSE ((0))
+
#define INT_MAX ((int)(~0U>>1))
#define INT_MIN (-INT_MAX - 1)
#define UINT_MAX (~0U)
diff -puN include/linux/ps2esdi.h~consolidate-true-and-false include/linux/ps2esdi.h
--- devel/include/linux/ps2esdi.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/include/linux/ps2esdi.h 2006-03-16 02:01:02.000000000 -0800
@@ -85,9 +85,6 @@
#define HDIO_GETGEO 0x0301
-#define FALSE 0
-#define TRUE !FALSE
-
struct ps2esdi_geometry {
unsigned char heads;
unsigned char sectors;
diff -puN include/linux/synclink.h~consolidate-true-and-false include/linux/synclink.h
--- devel/include/linux/synclink.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/include/linux/synclink.h 2006-03-16 02:01:02.000000000 -0800
@@ -14,8 +14,6 @@
#define SYNCLINK_H_VERSION 3.6
#define BOOLEAN int
-#define TRUE 1
-#define FALSE 0
#define BIT0 0x0001
#define BIT1 0x0002
diff -puN include/net/irda/irda.h~consolidate-true-and-false include/net/irda/irda.h
--- devel/include/net/irda/irda.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/include/net/irda/irda.h 2006-03-16 02:01:02.000000000 -0800
@@ -34,14 +34,6 @@
typedef __u32 magic_t;
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
/* Hack to do small backoff when setting media busy in IrLAP */
#ifndef SMALL
#define SMALL 5
diff -puN sound/oss/aedsp16.c~consolidate-true-and-false sound/oss/aedsp16.c
--- devel/sound/oss/aedsp16.c~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/sound/oss/aedsp16.c 2006-03-16 02:01:02.000000000 -0800
@@ -274,12 +274,6 @@
#endif
/*
- * Misc definitions
- */
-#define TRUE 1
-#define FALSE 0
-
-/*
* Region Size for request/check/release region.
*/
#define IOBASE_REGION_SIZE 0x10
diff -puN sound/oss/os.h~consolidate-true-and-false sound/oss/os.h
--- devel/sound/oss/os.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
+++ devel-akpm/sound/oss/os.h 2006-03-16 02:01:02.000000000 -0800
@@ -25,9 +25,6 @@
#include <linux/soundcard.h>
-#define FALSE 0
-#define TRUE 1
-
extern int sound_alloc_dma(int chn, char *deviceID);
extern int sound_open_dma(int chn, char *deviceID);
extern void sound_free_dma(int chn);
_
Hi,
On Thu, 16 Mar 2006, [email protected] wrote:
> From: Andrew Morton <[email protected]>
>
> We have no less than 65 implementations of TRUE and FALSE in the tree, so the
> inevitable happened:
[snip
>
> The patch implements TRUE and FALSE in include/linux/kernel.h and removes all
> the private versions.
Great! That has really been long overdue.
> Various places are doing things like
>
> typedef {
> FALSE,
> TRUE
> } my_fave_name_for_a_bool;
>
> These are converted to
>
> typedef int my_fave_name_for_a_bool;
Given that the kernel now requires gcc 3.2 or later, that already includes
a native boolean type (_Bool)? Why not use that instead of "int"?
Also <stdbool.h> contains:
#define bool _Bool
#define true 1
#define false 0
So we could take the bool rather than _Bool, too given _Bool looks
rather ugly...
We could even go as far as removing all those typedefs and replacing all
their uses with the native boolean type (or the "bool" define or
whatever). Seems like the perfect janitorial task to me. (-;
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
On Thu, 2006-03-16 at 02:01 -0800, [email protected] wrote:
> From: Andrew Morton <[email protected]>
>
> We have no less than 65 implementations of TRUE and FALSE in the tree, so the
> inevitable happened:
makes me wonder how many of these users should actually just use 0 and 1
directly (but that's a long during janitor task I guess)
Anton Altaparmakov <[email protected]> wrote:
>
> > Various places are doing things like
> >
> > typedef {
> > FALSE,
> > TRUE
> > } my_fave_name_for_a_bool;
> >
> > These are converted to
> >
> > typedef int my_fave_name_for_a_bool;
>
> Given that the kernel now requires gcc 3.2 or later, that already includes
> a native boolean type (_Bool)?
It does?
Is it any good?
bix:/home/akpm> cat t.c
void foo()
{
_Bool b = 1;
b += 2;
}
bix:/home/akpm> gcc -O -Wall -c t.c
bix:/home/akpm>
Sigh.
> Why not use that instead of "int"?
That'd be a separate patch ;)
> Also <stdbool.h> contains:
>
> #define bool _Bool
> #define true 1
> #define false 0
>
> So we could take the bool rather than _Bool, too given _Bool looks
> rather ugly...
We have a couple of private bools and a couple of private 'true's and
`false's so I guess it'd be a simple patch. I wonder if it would have any
surprising side-effects.
(I think using `bool' is a good thing - it makes the code more readable.
It's a shame the compiler's handling of it is so useless).
> The patch implements TRUE and FALSE in include/linux/kernel.h and removes all
> the private versions.
>
> The patch also kills off a few private implementations of NULL.
NACK. Just kill them all and use 0/1
On Thu, 16 Mar 2006 16:01:30 +0000 Christoph Hellwig wrote:
> > The patch implements TRUE and FALSE in include/linux/kernel.h and removes all
> > the private versions.
> >
> > The patch also kills off a few private implementations of NULL.
>
> NACK. Just kill them all and use 0/1
nah, the only place that using symbolic names for true and false
is a problem is when someone #defines or enums them bassackwards.
---
~Randy
On Thu, Mar 16, 2006 at 08:29:51AM -0800, Randy.Dunlap wrote:
> On Thu, 16 Mar 2006 16:01:30 +0000 Christoph Hellwig wrote:
>
> > > The patch implements TRUE and FALSE in include/linux/kernel.h and removes all
> > > the private versions.
> > >
> > > The patch also kills off a few private implementations of NULL.
> >
> > NACK. Just kill them all and use 0/1
>
> nah, the only place that using symbolic names for true and false
> is a problem is when someone #defines or enums them bassackwards.
it makes the code longer and harder to read. there's a reason the core
code doesn't use it, and the periphal code should do the same.
On Thu, 16 Mar 2006 16:30:01 +0000 Christoph Hellwig wrote:
> On Thu, Mar 16, 2006 at 08:29:51AM -0800, Randy.Dunlap wrote:
> > On Thu, 16 Mar 2006 16:01:30 +0000 Christoph Hellwig wrote:
> >
> > > > The patch implements TRUE and FALSE in include/linux/kernel.h and removes all
> > > > the private versions.
> > > >
> > > > The patch also kills off a few private implementations of NULL.
> > >
> > > NACK. Just kill them all and use 0/1
> >
> > nah, the only place that using symbolic names for true and false
> > is a problem is when someone #defines or enums them bassackwards.
>
> it makes the code longer and harder to read. there's a reason the core
> code doesn't use it, and the periphal code should do the same.
in your opinion.
---
~Randy
> > it makes the code longer and harder to read. there's a reason the core
> > code doesn't use it, and the periphal code should do the same.
>
> in your opinion.
of course. but that it's not used in core code implies this opinion is
widely shared.
On Thu, 16 Mar 2006 16:36:21 +0000 Christoph Hellwig wrote:
> > > it makes the code longer and harder to read. there's a reason the core
> > > code doesn't use it, and the periphal code should do the same.
> >
> > in your opinion.
>
> of course. but that it's not used in core code implies this opinion is
> widely shared.
well I'll be happy to leave it up to Andrew to work out. :)
---
~Randy
On Thu, 16 Mar 2006, Christoph Hellwig wrote:
> On Thu, Mar 16, 2006 at 08:29:51AM -0800, Randy.Dunlap wrote:
> > On Thu, 16 Mar 2006 16:01:30 +0000 Christoph Hellwig wrote:
> >
> > > > The patch implements TRUE and FALSE in include/linux/kernel.h and removes all
> > > > the private versions.
> > > >
> > > > The patch also kills off a few private implementations of NULL.
> > >
> > > NACK. Just kill them all and use 0/1
NACK to your NACK. (-;
> > nah, the only place that using symbolic names for true and false
> > is a problem is when someone #defines or enums them bassackwards.
>
> it makes the code longer and harder to read.
I could not disagree more. It does _exactly_ the opposite. It makes the
code much easier to read but obviously you perceive it differently... I
guess it is very much a matter of taste rather than anything else.
For me, black and white is much simpler than shades of grey and whilst you
can emulate black and white with shades of grey it is still more effort to
parse than true black and white.
Certainly I refuse to have my booleans (in the kernel or anywhere else)
converted to 0 and 1 but I am all for unifying to a single boolean type
across the kernel, so this patch gets a big ACK from me.
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
On Thu, 16 Mar 2006, Christoph Hellwig wrote:
> > > it makes the code longer and harder to read. there's a reason the core
> > > code doesn't use it, and the periphal code should do the same.
> >
> > in your opinion.
>
> of course. but that it's not used in core code implies this opinion is
> widely shared.
Again, in your opinion. To me it is a simple consequence of there not
being a boolean type in the kernel so you cannot use it in the core code.
Once there is such a type I would imagine users will appear in the core
code over time.
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
On Thu, Mar 16, 2006 at 02:01:28AM -0800, [email protected] wrote:
>
> From: Andrew Morton <[email protected]>
>
> 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.
..oO[and no, #define BEGIN { is also not kernel.h fodder]
On Thu, Mar 16, 2006 at 04:42:29PM +0000, Anton Altaparmakov wrote:
> Again, in your opinion. To me it is a simple consequence of there not
> being a boolean type in the kernel so you cannot use it in the core code.
> Once there is such a type I would imagine users will appear in the core
> code over time.
And that's supposed to be an argument in favour of that crap?
On Thu, Mar 16, 2006 at 02:01:28AM -0800, [email protected] wrote:
>
> From: Andrew Morton <[email protected]>
>
> 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
I have a patch in my queue that fixes this, in the ibmphp driver.
The acpi stuff should still be fixed though...
thanks,
greg k-h
On Thu, 2006-03-16 at 17:01, Christoph Hellwig wrote:
> > The patch implements TRUE and FALSE in include/linux/kernel.h and removes all
> > the private versions.
> >
> > The patch also kills off a few private implementations of NULL.
>
> NACK. Just kill them all and use 0/1
I'd say use var == 0 and var != 0 (or var and !var).
While FALSE is obviously 0, TRUE isn't only 1.
Xav
On Thu, Mar 16, 2006 at 09:05:05AM -0800, Ray Lee wrote:
> > And that's supposed to be an argument in favour of that crap?
>
> So an honest, if stupid, question: How is the TRUE/FALSE stuff any
> different than the case of using a NULL when assigning a zero to a
> pointer is explicitly required to have the same effect? They both
> seem to further the goal of better self-documenting code.
NULL is idiomatic in C. TRUE and FALSE are definitely not. Again,
if you want Bournegol, you know where to find it. Grab the v7 sh
and enjoy "self-documenting" code.
On Thu, Mar 16, 2006 at 09:07:35AM -0800, Greg KH wrote:
> On Thu, Mar 16, 2006 at 02:01:28AM -0800, [email protected] wrote:
> >
> > From: Andrew Morton <[email protected]>
> >
> > 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
>
> I have a patch in my queue that fixes this, in the ibmphp driver.
Pushed out into my tree now, if you want to update your copy.
thanks,
greg k-h
On Thu, Mar 16, 2006 at 04:30:01PM +0000, Christoph Hellwig wrote:
> it makes the code longer and harder to read. there's a reason the core
> code doesn't use it, and the periphal code should do the same.
Let see:
0 is an interger zero. It is not a null pointer.
1 is an interger one
NULL is an null pointer
We agree so far?
And you say:
0 is also false
1 is also true
But others say:
0 is not false, only false is false.
1 is not true, only true is true.
Thats more readable. No magic = 1; assignments or return 1; things.
Then we will have the case where a 1 is transformed to a true, and
likewise a 0 to a false. But thats just normal type conversion.
I assume that when you are not used to see 'bool', 'true' and 'false'
then they hurt the eye, but when used to it it looks natural.
Sam
On Thu, Mar 16, 2006 at 06:41:12PM +0100, Sam Ravnborg wrote:
> I assume that when you are not used to see 'bool', 'true' and 'false'
> then they hurt the eye, but when used to it it looks natural.
Five words: kernel is written in C.
Not in Pascal. Not in C++. Not in Algol. "When used to (something
non-idiomatic in C) it becomes natural" is not a valid argument.
On Thu, 16 Mar 2006 18:00:47 +0000 Al Viro wrote:
> On Thu, Mar 16, 2006 at 06:41:12PM +0100, Sam Ravnborg wrote:
> > I assume that when you are not used to see 'bool', 'true' and 'false'
> > then they hurt the eye, but when used to it it looks natural.
>
> Five words: kernel is written in C.
>
> Not in Pascal. Not in C++. Not in Algol. "When used to (something
> non-idiomatic in C) it becomes natural" is not a valid argument.
C (C99) now includes booleans. Are we stuck pre-C99?
---
~Randy
On Thu, 16 Mar 2006, Al Viro wrote:
> On Thu, Mar 16, 2006 at 04:42:29PM +0000, Anton Altaparmakov wrote:
> > Again, in your opinion. To me it is a simple consequence of there not
> > being a boolean type in the kernel so you cannot use it in the core code.
> > Once there is such a type I would imagine users will appear in the core
> > code over time.
>
> And that's supposed to be an argument in favour of that crap?
No, it was an alternative interpretation to Christoph's statement that the
non-use of booleans was due to them being crap. So I said that you can't
use what you don't have and I imagine the majority of people do not want
these pointless flamewars so no-one has so far bothered to introduce a
generic bollean type in the kernel...
Andy why is it crap? For a start it is valid C (well, ok C99, but even
you are fond of a lot of C99 features like the initializers) and second
it makes code more readable and makes meaning of functions a lot more
obvious, e.g reading:
"extern bool foo_is_compressed(bar);"
in a header file makes it damn obvious that if foo_is_compressed() returns
"true" then "bar" is compressed and if it returns "false" then "bar" is
not compressed.
If you see:
"extern int foo_is_compressed(bar);"
You have to go find the .c file containing the function and read it to
figure out what the heck the return value means/is. And don't tell me you
can rely on it returning 0 for not-compressed and 1 for compressed. For a
start it could return < 0 for error and a myriad of other things.
Especially in the kernel core the functions like that seem to randomly
return 0 for true and 1 for false and worse. But even if they were
consistent you could never rule out the < 0 for error case unless you read
the function itself.
So I beg to differ with your opinion of boolean type being crap.
As you might have noticed already, I think booleans have their place and
make code much more readable when used appropriately. I have only been
programming for the last 24 years and I like booleans and no-one is going
to get me to think otherwise after such a long time...
I am happy to agree that we disagree. Just stay away with s/true/1/
and s/false/0/ conversions from fs/ntfs/ please and I will shut up... (-:
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
On Thu, Mar 16, 2006 at 10:12:20AM -0800, Randy.Dunlap wrote:
> On Thu, 16 Mar 2006 18:00:47 +0000 Al Viro wrote:
>
> > On Thu, Mar 16, 2006 at 06:41:12PM +0100, Sam Ravnborg wrote:
> > > I assume that when you are not used to see 'bool', 'true' and 'false'
> > > then they hurt the eye, but when used to it it looks natural.
> >
> > Five words: kernel is written in C.
> >
> > Not in Pascal. Not in C++. Not in Algol. "When used to (something
> > non-idiomatic in C) it becomes natural" is not a valid argument.
>
> C (C99) now includes booleans. Are we stuck pre-C99?
TRUE and FALSE are not those. Your point is...?
On Thu, Mar 16, 2006 at 06:00:47PM +0000, Al Viro wrote:
> On Thu, Mar 16, 2006 at 06:41:12PM +0100, Sam Ravnborg wrote:
> > I assume that when you are not used to see 'bool', 'true' and 'false'
> > then they hurt the eye, but when used to it it looks natural.
>
> Five words: kernel is written in C.
Yep - and bool, true and false are part of 'C' - C99.
>
> Not in Pascal. Not in C++. Not in Algol. "When used to (something
> non-idiomatic in C) it becomes natural" is not a valid argument.
The translation of idiomatic in my dictionary makes bool, true, false
far more idiomatic in the C than NULL.
But history has thaugth us to accept NULL with screaming UPPERCASE
where a null would be idiomatic C.
Sam
On Thu, 16 Mar 2006, Anton Altaparmakov wrote:
> On Thu, 16 Mar 2006, Al Viro wrote:
> > On Thu, Mar 16, 2006 at 04:42:29PM +0000, Anton Altaparmakov wrote:
> > > Again, in your opinion. To me it is a simple consequence of there not
> > > being a boolean type in the kernel so you cannot use it in the core code.
> > > Once there is such a type I would imagine users will appear in the core
> > > code over time.
> >
> > And that's supposed to be an argument in favour of that crap?
>
> No, it was an alternative interpretation to Christoph's statement that the
> non-use of booleans was due to them being crap. So I said that you can't
> use what you don't have and I imagine the majority of people do not want
> these pointless flamewars so no-one has so far bothered to introduce a
> generic bollean type in the kernel...
>
> Andy why is it crap? For a start it is valid C (well, ok C99, but even
s/Andy/And/...
> you are fond of a lot of C99 features like the initializers) and second
> it makes code more readable and makes meaning of functions a lot more
> obvious, e.g reading:
>
> "extern bool foo_is_compressed(bar);"
>
> in a header file makes it damn obvious that if foo_is_compressed() returns
> "true" then "bar" is compressed and if it returns "false" then "bar" is
> not compressed.
>
> If you see:
>
> "extern int foo_is_compressed(bar);"
>
> You have to go find the .c file containing the function and read it to
> figure out what the heck the return value means/is. And don't tell me you
> can rely on it returning 0 for not-compressed and 1 for compressed. For a
> start it could return < 0 for error and a myriad of other things.
> Especially in the kernel core the functions like that seem to randomly
> return 0 for true and 1 for false and worse. But even if they were
> consistent you could never rule out the < 0 for error case unless you read
> the function itself.
>
> So I beg to differ with your opinion of boolean type being crap.
>
> As you might have noticed already, I think booleans have their place and
> make code much more readable when used appropriately. I have only been
> programming for the last 24 years and I like booleans and no-one is going
> to get me to think otherwise after such a long time...
>
> I am happy to agree that we disagree. Just stay away with s/true/1/
> and s/false/0/ conversions from fs/ntfs/ please and I will shut up... (-:
>
> Best regards,
>
> Anton
>
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
On Thu, 16 Mar 2006 18:49:46 +0000 Al Viro wrote:
> On Thu, Mar 16, 2006 at 10:12:20AM -0800, Randy.Dunlap wrote:
> > On Thu, 16 Mar 2006 18:00:47 +0000 Al Viro wrote:
> >
> > > On Thu, Mar 16, 2006 at 06:41:12PM +0100, Sam Ravnborg wrote:
> > > > I assume that when you are not used to see 'bool', 'true' and 'false'
> > > > then they hurt the eye, but when used to it it looks natural.
> > >
> > > Five words: kernel is written in C.
> > >
> > > Not in Pascal. Not in C++. Not in Algol. "When used to (something
> > > non-idiomatic in C) it becomes natural" is not a valid argument.
> >
> > C (C99) now includes booleans. Are we stuck pre-C99?
>
> TRUE and FALSE are not those. Your point is...?
Correct. So it would be better if they were spelled 'true' and 'false',
as in the C99 spec?
---
~Randy
On Thu, 2006-03-16 at 02:42 -0800, Andrew Morton wrote:
> Anton Altaparmakov <[email protected]> wrote:
> >
> > > Various places are doing things like
> > >
> > > typedef {
> > > FALSE,
> > > TRUE
> > > } my_fave_name_for_a_bool;
> > >
> > > These are converted to
> > >
> > > typedef int my_fave_name_for_a_bool;
> >
> > Given that the kernel now requires gcc 3.2 or later, that already includes
> > a native boolean type (_Bool)?
>
> It does?
>
> Is it any good?
>
> bix:/home/akpm> cat t.c
> void foo()
> {
> _Bool b = 1;
>
> b += 2;
> }
> bix:/home/akpm> gcc -O -Wall -c t.c
> bix:/home/akpm>
>
> Sigh.
>
If you were to read the value of b after "b += 2", you'd find that b is
still 1.
Also note that _Bool is a byte, so anything that exposed its own custom
boolean type to userspace needs to be carefully updated.
--
Nicholas Miell <[email protected]>
>
>Is it any good?
>
Depends.
20:51 shanghai:/dev/shm > cat bool.c
#include <stdio.h>
int main(void) {
_Bool x = 0;
x += 2;
printf("%d\n", x);
}
20:51 shanghai:/dev/shm > gcc bool.c && ./a.out
1
It can't "overflow". If that's good or not I can't tell, and I can only
imagine an artifical scenario where it affects things:
void do_something_wrong(int *x) {
*x += 2;
}
int x = 0;
do_something_wrong(&x);
if(x & 1)
printf("x & 1");
>From this one, we would expect nothing to be printed. But if x was a _Bool
x (and _Bool *x, respectively), something would be printed.
Jan Engelhardt
--
>> of course. but that it's not used in core code implies this opinion is
>> widely shared.
>
>[...] To me it is a simple consequence of there not
>being a boolean type in the kernel so you cannot use it in the core code.
typedef bool int;
And then happily use if(EXPR) and if(!EXPR) instead of if(EXPR == TRUE) or
if(EXPR == FALSE). :-)
But typedeffing it to int (or unsigned char, if someone likes that
for space optimization) does not "catch overflows" (see another lkml
mail from me) as _Bool would.
Jan Engelhardt
--
On Thu, 16 Mar 2006 08:29:51 PST, "Randy.Dunlap" said:
> nah, the only place that using symbolic names for true and false
> is a problem is when someone #defines or enums them bassackwards.
Or goes off the deep end and does something like:
enum bool = {false, true, unknown};
http://thedailywtf.com/forums/47844/ShowPost.aspx
http://thedailywtf.com/forums/61792/ShowPost.aspx
Gaak. Unfortunately, they might someday try to write kernel code. ;)
>
> Or goes off the deep end and does something like:
>
> enum bool = {false, true, unknown};
Sounds like some of my AI code.
Al Viro <[email protected]> wrote:
>
> On Thu, Mar 16, 2006 at 02:01:28AM -0800, [email protected] wrote:
> >
> > From: Andrew Morton <[email protected]>
> >
> > 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).
On Thu, 16 Mar 2006, Jan Engelhardt wrote:
> >> of course. but that it's not used in core code implies this opinion is
> >> widely shared.
> >
> >[...] To me it is a simple consequence of there not
> >being a boolean type in the kernel so you cannot use it in the core code.
>
> typedef bool int;
You mean typedef int bool...
That (or its derivative) is what at least 69 places in the kernel do
already. That is the whole point of discussion! The point is to unify it
all into a kernel common place. I just suggested that using the compiler
provided _Bool was better than using int.
> And then happily use if(EXPR) and if(!EXPR) instead of if(EXPR == TRUE) or
> if(EXPR == FALSE). :-)
Obviously. No-one here is suggesting to use if (EXPR == TRUE) that is
crazy. You would use if (EXPR) no matter what type you use. Technically
only a boolean type should be used like that. The fact it works for an
int is concidence because false = 0 and true = 1.
The point is 1) when assigning, you assign x = FALSE; rather than x = 0;
which means nothing (it could be a counter you are initializing, no way to
tell) and 2) for return values from functions and parameters to functions
so it is easier to understand the semantics of the function.
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
Randy.Dunlap wrote:
>nah, the only place that using symbolic names for true and false
>is a problem is when someone #defines or enums them bassackwards.
Here's another danger associated with #define TRUE:
int x = ...;
if (x == TRUE)
do_something();
A surprise happens if x is initialized to something other than 0 or 1.
Looks like there maybe as many as a hundred instances of the above
pattern in the kernel. Most of them seem safe, but I don't know whether
they all are, and there are too many for me to check them all.
For instance, take a look at net/core/ethtool.c:ethtool_set_rx_csum()
and drivers/net/ixgb/ixgb_ethtool.c:ixgb_set_rx_csum() and
drivers/net/ixgb/ixgb_main.c:ixgb_configure_rx() for how it handles
adapter->rx_csum to see one example that strikes me as dubious.
On Thu, 16 Mar 2006 13:26:39 -0800
Andrew Morton <[email protected]> wrote:
> 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.
Isn't there a runtime cost converting all "non-false" values to a unique "true" (i.e. converting non-zero values to one) ?
I mean:
bool res = strcmp(string, "whatever");
if(res)
something_else();
... will convert res to 0 or 1, which is totally useless except perhaps for comprehension (and again, not for Al Viro for example :)
Xav
Xavier Bestel <[email protected]> wrote:
>
> On Thu, 16 Mar 2006 13:26:39 -0800
> Andrew Morton <[email protected]> wrote:
>
> > 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.
>
> Isn't there a runtime cost converting all "non-false" values to a unique "true" (i.e. converting non-zero values to one) ?
Yes, there will be. If people do wrong things.
> I mean:
>
> bool res = strcmp(string, "whatever");
> if(res)
> something_else();
There's an implicit conversion from integer (-1, 0, 1) to boolean there.
It _should_ require a typecast or, better,
bool res = (strcmp(...) != 0);
But it won't require that - the compiler will just accept it.. A new `gcc
--implement-bools-properly' or perhaps sparse should warn about the above.
(Hopefully the compiler would have the brains to optimise it all away in
this specific example).
But yeah, it's always possible to deoptimise your code.
>
>Isn't there a runtime cost converting all "non-false" values to a unique "true" (i.e. converting non-zero values to one) ?
>
Somewhat. The answer is "yes, but depends on usage". If you just
write
_Bool x = filthy_action();
if(x)
Then the compiler is smart enough to optimize 'x' away if it is not used
somewhere else, therefore we do not pay a price for converting the return
type of filthy_action (=int) to a _Bool.
The asm output for storing the result of filthy_action() [requires
'volatile int x' in this small example]
call strxcmp
mov [ebp-4], eax
While making that a 'volatile _Bool x' makes it:
call strxcmp
test eax, eax
setnz al
mov [ebp-1], al
Makes me prefer typedef int bool over _Bool.
Jan Engelhardt
--
Le 18/3/2006, "Jan Engelhardt" <[email protected]> a ?crit:
>>
>>Isn't there a runtime cost converting all "non-false" values to a unique "true" (i.e. converting non-zero values to one) ?
>>
>
>Somewhat. The answer is "yes, but depends on usage". If you just
>write
>
> _Bool x = filthy_action();
> if(x)
>
>Then the compiler is smart enough to optimize 'x' away if it is not used
>somewhere else, therefore we do not pay a price for converting the return
>type of filthy_action (=int) to a _Bool.
Actually I find this behavior very good
Xavier
Hi all
(and sorry Andrew for the double-mailing, hit the wrong button)
[email protected] wrote:
>diff -puN include/linux/kernel.h~consolidate-true-and-false include/linux/kernel.h
>--- devel/include/linux/kernel.h~consolidate-true-and-false 2006-03-16 02:01:02.000000000 -0800
>+++ devel-akpm/include/linux/kernel.h 2006-03-16 02:01:02.000000000 -0800
>@@ -18,6 +18,13 @@
>
> extern const char linux_banner[];
>
>+/*
>+ * Give these a funny-looking definition to improve the chances of them
>+ * clashing with other definitions of TRUE and FALSE, causing a cpp error
>+ */
>+#define TRUE ((1))
>+#define FALSE ((0))
>+
> #define INT_MAX ((int)(~0U>>1))
> #define INT_MIN (-INT_MAX - 1)
> #define UINT_MAX (~0U)
>
Just an alternative implementation, letting "true" be true and "false"
be false.
Also making it similar to GCC's library.
Signed-off-by: Richard Knutsson <[email protected]>
---
diff -Narup a/include/linux/stdbool.h b/include/linux/stdbool.h
--- a/include/linux/stdbool.h 1970-01-01 01:00:00.000000000 +0100
+++ b/include/linux/stdbool.h 2006-03-20 04:15:47.000000000 +0100
@@ -0,0 +1,15 @@
+/**
+ * Boolean handling
+ */
+#ifndef _STDBOOL_H /* Same name as in GCC's include/stdbool.h */
+#define _STDBOOL_H
+
+typedef _Bool bool;
+
+#define true ((0==0))
+#define false ((!true))
+
+#define TRUE true
+#define FALSE false
+
+#endif
diff -Narup a/include/linux/types.h b/include/linux/types.h
--- a/include/linux/types.h 2006-03-19 23:47:06.000000000 +0100
+++ b/include/linux/types.h 2006-03-20 03:51:39.000000000 +0100
@@ -3,6 +3,7 @@
#ifdef __KERNEL__
#include <linux/config.h>
+#include <linux/stdbool.h>
#define BITS_TO_LONGS(bits) \
(((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)