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



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/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: Front end website full-text search
    ... -- a @boolean type of null means a phrase based search ... DECLARE @whitespace INT ... Looking for a SQL Server replication book? ...
    (microsoft.public.sqlserver.fulltext)
  • Re: search error
    ... -- a @boolean type of null means a phrase based search ... -- a @boolean type of 2 means an AND type search ... declare @whitespace int ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Which numbers evaluate to true and false?
    ... compared to an int used as a boolean type. ... You still need to know though that it is really just an int and that zero is interpreted as `false' and non-zero as `true'. ...
    (comp.lang.c)
  • Re: Searching for
    ... -- a @boolean type of null means a phrase based search ... declare @holdingString varchar ... declare @whitespace int ... Given there's a lot of items in a database> and the user is looking for a "10 inch wrench" he/she is probably typing> "wrench 10 inch". ...
    (microsoft.public.sqlserver.fulltext)
  • Re: [patch 1/1] consolidate TRUE and FALSE
    ... being a boolean type in the kernel so you cannot use it in the core code. ... for space optimization) does not "catch overflows" (see another lkml ...
    (Linux-Kernel)

Loading