From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753343AbcBAQOY (ORCPT ); Mon, 1 Feb 2016 11:14:24 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:51308 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752922AbcBAQOV (ORCPT ); Mon, 1 Feb 2016 11:14:21 -0500 From: Arnd Bergmann To: One Thousand Gnomes Cc: gregkh@linuxfoundation.org, Greg Hackmann , Jin Qian , Alan Cox , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] staging: goldfish: use div64_s64 instead of do_div Date: Mon, 01 Feb 2016 17:13:44 +0100 Message-ID: <2123401.bK87U6BMYJ@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20160201145457.7879d53f@lxorguk.ukuu.org.uk> References: <1676170.0qik6mzm6D@wuerfel> <20160201145457.7879d53f@lxorguk.ukuu.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:l1oWYw3TfEEFUBdLC598clMEAMDEL15/Hrb9GaygBcZfZpALQ9W 6jSejl3AYnISBmSvfAPfFdcNiK1DzpCvJjz/sfndKhLXU5N88kL4RvYXzRTFuzc5bF8UTqY Qjsg5AOpr3wN4bwtiDaD+p8mXosahIRtURI4fgfpbFJACfM1ewhssIoJ7VvztCTJzU0+GGR aYzOAjey6JFwViuCAgJzA== X-UI-Out-Filterresults: notjunk:1;V01:K0:m2Abf9tXSSc=:e89TEY1QFvyjiVHAeFBGrF 0k7uImwmJpoqBgaVuJF8+UW7Ahq4GuWmhQ5Nc2F8lL00HFWfMaYU/98C41oyrLo8agJRRV3O4 xwI9We5t40SMdbV/VWo2Hs+o4hzulH/3DpVslKCj8fab5B/5NcdtlrU0A7kQCjKCIJPgJRbIS Z+fCdKimHK7Lt5OX+7QjBpDDMBlRAQJYzLRE7BYHNig/N0WtJRh2tU26cFIb2WLoewkJ47zyk 15/1epF5FvC5QK+29cFu8mnBWtNxPpekWhfcXxQmEGJee/179FHebFqI53bnZNmax7LXQLmHj Qz6zZPEBT4B357mle5erncPw8wZZLD1LivbaWiMopR85k/T6swJ3HIsw2eVW2PO4Qsc6MBZ0r 8YqeJioOdrQlB+uIMhdylZocBc7UMKihTKvTvVLr0nVbK88V+vzSyMBNV21vdvj6UDeLunOCf Uy2Qa7XkRX57yB6NoGdl1X5rfj/rEiFbgtCp8OEECDlx5irk5kXdssuwpYxffxhm1SLjVESdl D5Uc3ggvwNq0loME/LdY2kPQSb1seAeXpR0LqMnjovVoZFIJSd0hNXVVsjxd/2Dc+F4aBD8XR uUPn+De5MY5XPlGnmGx4gxOO+O1SzVMsSBWY0JLON3YctPgY9wuLFvTErUSqqIobNvdhk3m83 n6xH13gKceFrvB+Ub/6KAFv3+Ib3iI6q/zzkOThEXB5EocfrDduvxV4urML6t9XrArazmGI9S dj4l+0Rvm1B9cORh Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 01 February 2016 14:54:57 One Thousand Gnomes wrote: > On Mon, 01 Feb 2016 11:33 +0100 > Arnd Bergmann wrote: > > > The goldfish nand driver divides a signed 64-bit number (loff_t) > > in multiple places using the do_div() function. This has always > > been unreliable but now produces a compiler warning (since 4.5-rc1): > > > > goldfish/goldfish_nand.c: In function 'goldfish_nand_erase': > > goldfish/goldfish_nand.c:107:91: error: comparison of distinct pointer types lacks a cast [-Werror] > > goldfish/goldfish_nand.c: In function 'goldfish_nand_read_oob': > > goldfish/goldfish_nand.c:145:91: error: comparison of distinct pointer types lacks a cast [-Werror] > > > > This changes the code to the equivalent div_s64{,_rem} that > > works correctly for negative numbers (which we should never > > get here). > > We can't get negatives as you say so surely the right fix is a cast or to > fix mtd->writesize ? A cast won't work because the first argument to the do_div() macro is both input and output. It's not the mtd->writesize argument that is the problem here, but the 'ofs' argument that comes from the loff_t argument in mtdchar_read() and others (ultimately from the lseek/pread/pwrite/...) We could change all the function prototypes in struct mtd_info to use u64 instead of loff_t, but that involve change all MTD drivers and the subsystem. Arnd