Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756742Ab3DWPwa (ORCPT ); Tue, 23 Apr 2013 11:52:30 -0400 Received: from li9-11.members.linode.com ([67.18.176.11]:43920 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756558Ab3DWPw2 (ORCPT ); Tue, 23 Apr 2013 11:52:28 -0400 Date: Tue, 23 Apr 2013 11:52:12 -0400 From: "Theodore Ts'o" To: Linus Torvalds Cc: David Laight , Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , David Miller , Linux Kernel Mailing List , the arch/x86 maintainers , Network Development , "linux-ext4@vger.kernel.org" Subject: Re: Unsigned widening casts of binary "not" operations.. Message-ID: <20130423155212.GI31170@thunk.org> Mail-Followup-To: Theodore Ts'o , Linus Torvalds , David Laight , Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , David Miller , Linux Kernel Mailing List , the arch/x86 maintainers , Network Development , "linux-ext4@vger.kernel.org" References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1121 Lines: 21 On Tue, Apr 23, 2013 at 08:42:49AM -0700, Linus Torvalds wrote: > The best case is for code that does bitmasking ops like this to avoid > any casts (implicit or explicit) by just avoiding mixed types. That > was, to a large degree, my hope for the sparse patch, but it's > nontrivial. Many types are rather "natural" (ie constants have a > natural "int" type, sizeof() is size_t, etc) and in other cases you > want to do the same ops for two different types (with the case that > caused me to start to look at it being the "align to page boundary" > for a virtual address vs a PAE phys_addr_t) so you can't really avoid > mixing things in some circumstances. Maybe it's worth creating a magic helper function, called something like mask_out() that handles the casting automatically, and it makes it clear to a reader what you're trying to do? - Ted -- 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/