Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754966AbXJ3U7U (ORCPT ); Tue, 30 Oct 2007 16:59:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753002AbXJ3U7K (ORCPT ); Tue, 30 Oct 2007 16:59:10 -0400 Received: from gepetto.dc.ltu.se ([130.240.42.40]:50001 "EHLO gepetto.dc.ltu.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752872AbXJ3U7J (ORCPT ); Tue, 30 Oct 2007 16:59:09 -0400 Message-ID: <47279999.6090002@student.ltu.se> Date: Tue, 30 Oct 2007 21:52:41 +0100 From: Richard Knutsson User-Agent: Thunderbird 2.0.0.5 (X11/20070727) MIME-Version: 1.0 To: Matthew Wilcox 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 References: <20071030104806.30936.13253.sendpatchset@thinktank.campus.ltu.se> <20071030145155.GL32359@parisc-linux.org> <47274781.3030606@student.ltu.se> <20071030151121.GM32359@parisc-linux.org> <47275FD0.4010400@student.ltu.se> <20071030173828.GB15111@parisc-linux.org> In-Reply-To: <20071030173828.GB15111@parisc-linux.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1846 Lines: 42 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/