lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 30 Oct 2007 21:52:41 +0100
From:	Richard Knutsson <ricknu-0@...dent.ltu.se>
To:	Matthew Wilcox <matthew@....cx>
CC:	James.Bottomley@...elEye.com, linux-kernel@...r.kernel.org,
	linux-scsi@...r.kernel.org
Subject: Re: [PATCH] drivers/scsi/dpt_i2o: Convert to generic boolean

Matthew Wilcox wrote:
> On Tue, Oct 30, 2007 at 05:46:08PM +0100, Richard Knutsson wrote:
>   
>> I just don't see the reason why expressing a boolean as an integer. Some 
>> advantage?
>>     
>
> This is C, not Java, or some other highly-typed language.
> if (int) and if (ptr) are perfectly acceptable in C.
>   
Yes, and it has been "corrected" in the C99-standard (which we are using 
since the Linux support for the the 2.95 compiler stopped). Is there 
something wrong in actually typing the variable to the type we want it 
to be? Or would it be better to regress (becoming like Perl or PHP)[1][2]?
Btw, I am all for 'if (ptr)' since it rarely (if ever) makes any sense 
to do 'if (ptr == 0x1234)', which evaluates to ptr == NULL is invalid 
and otherwise valid. Is it really the same for integers? ;)
(also just want to add: to the "this is not a highly-typed language" 
that I have heard many times, it theory, I think it would suffice with 
just the void-pointer)
>   
>> (also helps us if someone does: 'if (var == true)', even thou we should 
>> try to avoid them)
>>     
>
> I have no idea what you mean.
>   
There is some places where things like 'if (var == true)' is done, but 
what happens when var is not the same number as 'true' (and still != 0)? 
It is a potential bug if 'var' is an integer and expected to be a 
boolean in this case. Like in a case of "var = some_var & some_flag;"

Best regards
Richard Knutsson
[1] Nothing wrong with Perl or PHP, they are suited for the tasks they 
are meant to solve.
[2] If I recall correctly, the predecessor 'B' did not have any types.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ