Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755604Ab2BAS6T (ORCPT ); Wed, 1 Feb 2012 13:58:19 -0500 Received: from mail-yx0-f174.google.com ([209.85.213.174]:55339 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754997Ab2BAS6R (ORCPT ); Wed, 1 Feb 2012 13:58:17 -0500 MIME-Version: 1.0 In-Reply-To: <20120201.130905.1131458895704793597.davem@davemloft.net> References: <20120201.130905.1131458895704793597.davem@davemloft.net> From: Linus Torvalds Date: Wed, 1 Feb 2012 10:57:57 -0800 X-Google-Sender-Auth: BnUjOShvBZCjh2Yb5RYHC8eYzqw Message-ID: Subject: Re: Memory corruption due to word sharing To: David Miller Cc: matz@suse.de, jkosina@suse.cz, walters@verbum.org, jack@suse.cz, linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, dsterba@suse.cz, ptesarik@suse.cz, rguenther@suse.de, gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1149 Lines: 27 On Wed, Feb 1, 2012 at 10:09 AM, David Miller wrote: > > Personally I've avoided C bitfields like the plague in any code I've > written. I do agree with that. The kernel largely tries to avoid bitfields, usually because we have some really strict rules about different bitfields, but also because initialization of bitfields tends to result in gcc generating an incredible mess of the code (while "explicit bits" allows us to just set all the fields in one go, and know what the result is). So core kernel data structures tend to be things like "unsigned long", together with our various bitop functions that have explicit atomicity (or non-atomicity) guarantees on a bit-per-bit basis. Sometimes bitfields are really convenient, though, and allow for much more natural syntax. I'm not surprised this issue came up in a filesystem, for example. 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/