All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Knutsson <ricknu-0@student.ltu.se>
To: Matthew Wilcox <matthew@wil.cx>
Cc: James.Bottomley@SteelEye.com, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH] drivers/scsi/dpt_i2o: Convert to generic boolean
Date: Tue, 30 Oct 2007 21:52:41 +0100	[thread overview]
Message-ID: <47279999.6090002@student.ltu.se> (raw)
In-Reply-To: <20071030173828.GB15111@parisc-linux.org>

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.

      reply	other threads:[~2007-10-30 20:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-30 10:54 [PATCH] drivers/scsi/dpt_i2o: Convert to generic boolean Richard Knutsson
2007-10-30 14:47 ` Salyzyn, Mark
2007-10-30 14:47   ` Salyzyn, Mark
2007-10-30 14:51 ` Matthew Wilcox
2007-10-30 15:02   ` Richard Knutsson
2007-10-30 15:11     ` Matthew Wilcox
2007-10-30 16:46       ` Richard Knutsson
2007-10-30 17:38         ` Matthew Wilcox
2007-10-30 20:52           ` Richard Knutsson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47279999.6090002@student.ltu.se \
    --to=ricknu-0@student.ltu.se \
    --cc=James.Bottomley@SteelEye.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=matthew@wil.cx \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.