Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754085AbdGNM2N (ORCPT ); Fri, 14 Jul 2017 08:28:13 -0400 Received: from mail-it0-f41.google.com ([209.85.214.41]:37488 "EHLO mail-it0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753573AbdGNM2L (ORCPT ); Fri, 14 Jul 2017 08:28:11 -0400 MIME-Version: 1.0 In-Reply-To: <20170714092540.1217397-8-arnd@arndb.de> References: <20170714092540.1217397-1-arnd@arndb.de> <20170714092540.1217397-8-arnd@arndb.de> From: Ard Biesheuvel Date: Fri, 14 Jul 2017 13:28:10 +0100 Message-ID: Subject: Re: [PATCH 07/14] proc/kcore: hide a harmless warning To: Arnd Bergmann Cc: "linux-kernel@vger.kernel.org" , Jiri Olsa , Greg Kroah-Hartman , Linus Torvalds , Tejun Heo , Guenter Roeck , linux-ide@vger.kernel.org, linux-media@vger.kernel.org, Andrew Morton , dri-devel@lists.freedesktop.org, Kees Cook , Ingo Molnar , Laura Abbott , Pratyush Anand Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v6ECSMnL008322 Content-Length: 1938 Lines: 49 On 14 July 2017 at 10:25, Arnd Bergmann wrote: > gcc warns when MODULES_VADDR/END is defined to the same value as > VMALLOC_START/VMALLOC_END, e.g. on x86-32: > > fs/proc/kcore.c: In function ‘add_modules_range’: > fs/proc/kcore.c:622:161: error: self-comparison always evaluates to false [-Werror=tautological-compare] > if (/*MODULES_VADDR != VMALLOC_START && */MODULES_END != VMALLOC_END) { > Does it occur for subtraction as well? Or only for comparison? > The code is correct as it is required for most other configurations. > The best workaround I found for shutting up that warning is to make > it a little more complex by adding a temporary variable. The compiler > will still optimize away the code as it finds the two to be identical, > but it no longer warns because it doesn't condider the comparison > "tautological" any more. > > Signed-off-by: Arnd Bergmann > --- > fs/proc/kcore.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c > index 45629f4b5402..c503ad657c46 100644 > --- a/fs/proc/kcore.c > +++ b/fs/proc/kcore.c > @@ -620,12 +620,14 @@ static void __init proc_kcore_text_init(void) > /* > * MODULES_VADDR has no intersection with VMALLOC_ADDR. > */ > -struct kcore_list kcore_modules; > +static struct kcore_list kcore_modules; > static void __init add_modules_range(void) > { > - if (MODULES_VADDR != VMALLOC_START && MODULES_END != VMALLOC_END) { > - kclist_add(&kcore_modules, (void *)MODULES_VADDR, > - MODULES_END - MODULES_VADDR, KCORE_VMALLOC); > + void *start = (void *)MODULES_VADDR; > + size_t len = MODULES_END - MODULES_VADDR; > + > + if (start != (void *)VMALLOC_START && len != VMALLOC_END - VMALLOC_START) { > + kclist_add(&kcore_modules, start, len, KCORE_VMALLOC); > } > } > #else > -- > 2.9.0 >