Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757195AbbGTX2E (ORCPT ); Mon, 20 Jul 2015 19:28:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43221 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755492AbbGTX2C (ORCPT ); Mon, 20 Jul 2015 19:28:02 -0400 Date: Mon, 20 Jul 2015 16:28:00 -0700 From: Andrew Morton To: Rasmus Villemoes Cc: Guenter Roeck , Sowmini Varadhan , linux-kernel@vger.kernel.org, benh@kernel.crashing.org, davem@davemloft.net Subject: Re: [PATCH] iommu-common: Do not use 64 bit constant 0xffffffffffffffffl for computing align_mask Message-Id: <20150720162800.734632f4e05ffae173cff527@linux-foundation.org> In-Reply-To: <87oaj6ogox.fsf@rasmusvillemoes.dk> References: <20150719121653.GA30645@oracle.com> <20150719152724.GB3729@roeck-us.net> <874mkzevz4.fsf@rasmusvillemoes.dk> <55AC55AD.6070608@roeck-us.net> <87oaj6ogox.fsf@rasmusvillemoes.dk> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 958 Lines: 26 On Mon, 20 Jul 2015 19:57:18 +0200 Rasmus Villemoes wrote: > On Mon, Jul 20 2015, Guenter Roeck wrote: > > > So either case ~0l appears to be wrong; it should be ~0ul. > > Yes, right-shifting -1 of any type is probably always wrong, as it will > always give -1 again. Not for unsigned types. The kernel uses "-1UL" and "-1ULL" quite a lot - it's a convenient way of saying "all ones, regardless of size". Also, assigning plain old "-1" to an unsigned variable will make that variable all-ones regardless of size. In this case I expect we could do align_mask = -1UL >> (64 - align_order); but I don't know about that 64. Maybe it should be BITS_PER_LONG? -- 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/