From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bw0-f42.google.com (mail-bw0-f42.google.com [209.85.214.42]) by ozlabs.org (Postfix) with ESMTP id D814FB6F01 for ; Tue, 14 Sep 2010 02:45:26 +1000 (EST) Received: by bwz7 with SMTP id 7so7064016bwz.15 for ; Mon, 13 Sep 2010 09:45:24 -0700 (PDT) Subject: Re: [PATCH v2 3/3][MTD] P4080/mtd: Fix the freescale lbc issue with 36bit mode From: Artem Bityutskiy To: Timur Tabi In-Reply-To: References: <1284027632-32573-1-git-send-email-tie-fei.zang@freescale.com> <1284027632-32573-2-git-send-email-tie-fei.zang@freescale.com> <1284027632-32573-3-git-send-email-tie-fei.zang@freescale.com> <20100909114153.GB6622@oksana.dev.rtsoft.ru> <3850A844E6A3854C827AC5C0BEC7B60A1FC158@zch01exm23.fsl.freescale.net> <1284388075.10955.51.camel@localhost> Content-Type: text/plain; charset="UTF-8" Date: Mon, 13 Sep 2010 19:45:20 +0300 Message-ID: <1284396320.1783.30.camel@brekeke> Mime-Version: 1.0 Cc: Wood Scott-B07421 , Zang Roy-R61911 , Lan Chunhe-B25806 , linuxppc-dev@ozlabs.org, linux-mtd@lists.infradead.org, akpm@linux-foundation.org, dwmw2@infradead.org, Gala Kumar-B11780 Reply-To: dedekind1@gmail.com List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Mon, 2010-09-13 at 09:35 -0500, Timur Tabi wrote: > On Mon, Sep 13, 2010 at 9:27 AM, Artem Bityutskiy wrote: > > > Yes, sizeof(int) == 4 assumption is not good. > > > > But sizeof(int) >= 4 is perfectly fine. > > I have to disagree. I don't see how you can say that == is not okay, > but >= is okay. If I assume that int == 4, which is true for all platform ATM, and will most probably stay true for very long time, I still make an unnecessary assumption which C99 does not guarantee. This is just not very clean. So for things which require exactly 32 bits, u32 or C99 uint32_t should be used. On the other hand, if a have a local variable "var" which needs to store values which I know will always fit 32 bits, and I do not use it in operations (I/O, etc) which require exactly 32 bits, it is better to use unsigned int for it. Unsigned int is reliably >= 4 in Linux. This is wat I meant that sizeof(int) >= 4 is perfectly fine. One everywhere, of course, but in many cases. To put it differently, if there is no special reason to limit the variable by exactly 32 bits, it is better to use int. -- Best Regards, Artem Bityutskiy (Битюцкий Артём) From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-bw0-f49.google.com ([209.85.214.49]) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OvC9l-00081A-JE for linux-mtd@lists.infradead.org; Mon, 13 Sep 2010 16:45:26 +0000 Received: by bwz13 with SMTP id 13so6085176bwz.36 for ; Mon, 13 Sep 2010 09:45:24 -0700 (PDT) Subject: Re: [PATCH v2 3/3][MTD] P4080/mtd: Fix the freescale lbc issue with 36bit mode From: Artem Bityutskiy To: Timur Tabi In-Reply-To: References: <1284027632-32573-1-git-send-email-tie-fei.zang@freescale.com> <1284027632-32573-2-git-send-email-tie-fei.zang@freescale.com> <1284027632-32573-3-git-send-email-tie-fei.zang@freescale.com> <20100909114153.GB6622@oksana.dev.rtsoft.ru> <3850A844E6A3854C827AC5C0BEC7B60A1FC158@zch01exm23.fsl.freescale.net> <1284388075.10955.51.camel@localhost> Content-Type: text/plain; charset="UTF-8" Date: Mon, 13 Sep 2010 19:45:20 +0300 Message-ID: <1284396320.1783.30.camel@brekeke> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: Wood Scott-B07421 , Zang Roy-R61911 , Lan Chunhe-B25806 , linuxppc-dev@ozlabs.org, linux-mtd@lists.infradead.org, Anton Vorontsov , akpm@linux-foundation.org, dwmw2@infradead.org, Gala Kumar-B11780 Reply-To: dedekind1@gmail.com List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Mon, 2010-09-13 at 09:35 -0500, Timur Tabi wrote: > On Mon, Sep 13, 2010 at 9:27 AM, Artem Bityutskiy wrote: > > > Yes, sizeof(int) == 4 assumption is not good. > > > > But sizeof(int) >= 4 is perfectly fine. > > I have to disagree. I don't see how you can say that == is not okay, > but >= is okay. If I assume that int == 4, which is true for all platform ATM, and will most probably stay true for very long time, I still make an unnecessary assumption which C99 does not guarantee. This is just not very clean. So for things which require exactly 32 bits, u32 or C99 uint32_t should be used. On the other hand, if a have a local variable "var" which needs to store values which I know will always fit 32 bits, and I do not use it in operations (I/O, etc) which require exactly 32 bits, it is better to use unsigned int for it. Unsigned int is reliably >= 4 in Linux. This is wat I meant that sizeof(int) >= 4 is perfectly fine. One everywhere, of course, but in many cases. To put it differently, if there is no special reason to limit the variable by exactly 32 bits, it is better to use int. -- Best Regards, Artem Bityutskiy (Битюцкий Артём)