Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763585AbXEYU4X (ORCPT ); Fri, 25 May 2007 16:56:23 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753172AbXEYU4Q (ORCPT ); Fri, 25 May 2007 16:56:16 -0400 Received: from an-out-0708.google.com ([209.85.132.243]:44738 "EHLO an-out-0708.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752533AbXEYU4Q (ORCPT ); Fri, 25 May 2007 16:56:16 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=e1SSoZ7Fxnx/h0x4oQgBnHNfFmZ8Yuw7HsrclnWaA0VhAjP7Q4wjkEOx/xWX5XL+99nQsEAZAWn+kxFJt/7K/vVWRw4J8yeQJzLdMkb7BU4iX9ziBP4NC5ligrpwFdGVOZNTfVLGtyAqbUP13a451fkqWvPaTuLF3Cp6ynU4WE0= Message-ID: Date: Sat, 26 May 2007 02:26:11 +0530 From: "Satyam Sharma" To: "Al Viro" Subject: Re: double exclamation (!!) suckage in the kernel Cc: "Linux Kernel Mailing List" In-Reply-To: <20070525204127.GK4095@ftp.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070525204127.GK4095@ftp.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1811 Lines: 50 On 5/26/07, Al Viro wrote: > On Sat, May 26, 2007 at 01:53:59AM +0530, Satyam Sharma wrote: > > Hello, > > > > Grepping through the sources I found 500+ occurrences of double > > exclamation marks before identifier names (such as !!x -- I took care > > to ignore occurrences of !! inside comment blocks, because there > > are plenty of that sort too). > > > > !! are to be found even in the definitions of common macros such as > > likely() and unlikely(), which hundreds of eyes must have seen over > > the last year or so ... > > > > Are all these occurrences merely the debris of > > s/something/!notsomething/g kind of patches or is there some > > dark, unknown C / gcc wizardry I have absolutely no clue of? > > That's a question for a quiz in introductory course on C: Ugh ... ok, I've embarrassed myself publicly already, so I'll also be brave enough to take a C quiz here :-) > what type should x have for !!x to be a valid expression? Any integer type (includes pointers) > what will be the type of result? int (I guess boolean for C99?) > what are the possible values of the result? {0, 1} > describe which values of x correspond to each possible value of !!x Russell's mail has already answered that ... > You have 10 minutes (and that's a fairly generous, actually). Hmmm, looking through the grep output, actually, it seems some of the occurrences of !! are indeed debris, but yes, most are actually a way to force the output to {0, 1} when dealing with individual bits in code. Satyam - 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/