Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752060AbYLWSJm (ORCPT ); Tue, 23 Dec 2008 13:09:42 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751016AbYLWSJc (ORCPT ); Tue, 23 Dec 2008 13:09:32 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:48003 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750986AbYLWSJb (ORCPT ); Tue, 23 Dec 2008 13:09:31 -0500 Date: Tue, 23 Dec 2008 10:08:50 -0800 (PST) From: Linus Torvalds X-X-Sender: torvalds@localhost.localdomain To: Krzysztof Halasa cc: Harvey Harrison , =?ISO-8859-15?Q?H=E5kon_L=F8vdal?= , Hannes Eder , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement In-Reply-To: Message-ID: References: <20081222191259.11807.53190.stgit@vmbox.hanneseder.net> <20081222191507.11807.50794.stgit@vmbox.hanneseder.net> <1230053186.1447.9.camel@brick> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1721 Lines: 43 On Tue, 23 Dec 2008, Krzysztof Halasa wrote: > Harvey Harrison writes: > > >> There are many ways to make the code more merge friendly at a cost of > >> readability. Hope we don't go this way. > > > > Linus himself added that particular warning to sparse...may want to check > > with him the reason for it. > > Once again, this is a personal thing, and a harmless one. It's more than that. I added the check after some person who had been programming the kernel (and thus was supposedly fluent in C) literally could not parse a macro that had "do x while (y)" in it. Why? Because it's so uncommon, and because "while (y)" on its own means something totally different. So the syntactic sugar to _always_ have do-while loops have that brace is a way to avoid one of the rather few places where the C language has syntax that is very context-dependent. Another example of this is "sizeof". The kernel universally (I hope) has parenthesis around the sizeof argument, even though it's clearly not required by the C language. It's a coding standard. And quite frankly, anybody who works on gcc has no place complaining about sparse coding standard warnings. They are a _hell_ of a lot better than some of the really crazy warnings gcc spews out with "-W". At least the sparse warnings you can make go away while making the code more understandable. Some of the -W warnings are unfixable without breaking the source code. Linus -- 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/