Message ID | 20230725134837.1534228-3-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2509213vqg; Tue, 25 Jul 2023 07:26:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlHLphYlT+Gb+PEhy7DXg2HHv0c+Eq42M+7nZQTxdTRD92+YB8Y9XN52LTqSj0qL9WzigjuP X-Received: by 2002:a17:902:a609:b0:1b9:de75:d5bb with SMTP id u9-20020a170902a60900b001b9de75d5bbmr14279065plq.7.1690295193197; Tue, 25 Jul 2023 07:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690295193; cv=none; d=google.com; s=arc-20160816; b=TXzYlxsmSVvysWNQt6nPNIO/ksJc4ZosUN3DMEuNxgIwYCFuTQTHYydtXbRC1kojnc 6rPgwfl+9BkginYpi/FBCQuJbK1Xq+tuJScKBmZFSHP+9299cjDzOYROwCTivO8ZvWdI l+fI3miNVIRLDheKqr5hkjLPTyQMQHhAifhWgcxnb7QUVbJlMUwEJfU+YaXL6KK120PA mEq8tSv4h2f8po80UAyETyn/JwRWxm0/NmQ9kzIXNYdTK6YYV2ctZSFPH3m2eUPyZxOM oyEGT0vdCbb0GflEneD7qPQggzxI4atAbOvBvWT+yIVh7fAlsBjhH+PgM7bGxigP9gBj kBkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DbK5jx3TdIjIeKj44d7qh47lS9C9C5DVRxUFx+zjI2g=; fh=R523ZnP4N7O48iGEbgKYBfM0eoofLeWRxo/bWq35Los=; b=S0iMAbZ2TKIyDxI1FWmNQrj5tj5zF+YnIUZCkpOhhP+Gsd+UQe2A1j+nfu9e0JJs/Z JC5fjXONMGLutXCqK7yxMHAzTdJEViim+qXvvOAytv4zJ0Ovv/W48ojoIhyE5VGBEAtK mjN6t7LgsS05SpZ2r28P4z5lUKQEx2h4N1zlHhawvHL8iv8lzueISwMLHygApIP+snAY Z19YpqipiB/WQxlte8aiFoQw6muAJNWsheZEhGlJhvhyf03BXZJELscRMCR1C0QfhKIz 5Hd6vOFXqiSGXXXfSnY1Rpl6mJU9Nvn9u7w56TwX3yPkXMdhGFbjgrkndyAg3dooLh15 z+zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SFLrP4GF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a170902da8800b001b8946f3f95si12020830plx.312.2023.07.25.07.26.19; Tue, 25 Jul 2023 07:26:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SFLrP4GF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231679AbjGYNtC (ORCPT <rfc822;kautuk.consul.80@gmail.com> + 99 others); Tue, 25 Jul 2023 09:49:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231599AbjGYNs6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 25 Jul 2023 09:48:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78A531FD0 for <linux-kernel@vger.kernel.org>; Tue, 25 Jul 2023 06:48:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C5BB46171E for <linux-kernel@vger.kernel.org>; Tue, 25 Jul 2023 13:48:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 609C0C433CA; Tue, 25 Jul 2023 13:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690292932; bh=v5mmMDcLa9Qz+qTohnDO/9Jf2svRDFSXLGnLYI1Fcc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SFLrP4GFqOQh1yYxfBN3ODV9bJRXnvbtT/GzhtfnMr9ePZxfUcUQ5Tpbu6wCPpWiv DEWidaqarR3eOw48om02/LZ0u+9Rm8NttxomDfeRglYP1kAkaxYz8U7vwU952avJxp 0z4EZWQHx9tE+V6WXJWWFalOHebK3xkhBjtd+p7wxI3Nz22nLbokLkXvbWjdjuZ6zX bgiBdi+0YLD8sUs2wGrHHeDRn18ppYuUEwtRBChFKIc+vtRklup8j10Wj6oeDl6/vG WnGaZP7eTI80FgbsesszEcFL11NNEu0hhaHcJNQsehnI1n5xnpbjlio1NAwdRNFEdd QQjkIiZqz2AyA== From: Arnd Bergmann <arnd@kernel.org> To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Arnd Bergmann <arnd@arndb.de>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, "H. Peter Anvin" <hpa@zytor.com> Subject: [PATCH 2/5] [RESEND] x86: avoid unneeded __div64_32 function definition Date: Tue, 25 Jul 2023 15:48:34 +0200 Message-Id: <20230725134837.1534228-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230725134837.1534228-1-arnd@kernel.org> References: <20230725134837.1534228-1-arnd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772402972844053750 X-GMAIL-MSGID: 1772402972844053750 |
Series |
remaining x86 -Wmissing-prototype warnings
|
|
Commit Message
Arnd Bergmann
July 25, 2023, 1:48 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> The __div64_32() function is provided for 32-bit architectures that don't have a custom do_div() implementation. x86_32 has one, and does not use the header file that declares the function prototype, so the definition causes a W=1 warning: lib/math/div64.c:31:32: error: no previous prototype for '__div64_32' [-Werror=missing-prototypes] Define an empty macro to prevent the function definition from getting built, which avoids the warning and saves a little .text space. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- arch/x86/include/asm/div64.h | 2 ++ 1 file changed, 2 insertions(+)
Comments
On Tue, Jul 25, 2023 at 03:48:34PM +0200, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > The __div64_32() function is provided for 32-bit architectures that > don't have a custom do_div() implementation. x86_32 has one, and > does not use the header file that declares the function prototype, > so the definition causes a W=1 warning: > > lib/math/div64.c:31:32: error: no previous prototype for '__div64_32' [-Werror=missing-prototypes] > > Define an empty macro to prevent the function definition from getting > built, which avoids the warning and saves a little .text space. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > arch/x86/include/asm/div64.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h > index b8f1dc0761e4b..9826d5fc12e34 100644 > --- a/arch/x86/include/asm/div64.h > +++ b/arch/x86/include/asm/div64.h > @@ -71,6 +71,8 @@ static inline u64 mul_u32_u32(u32 a, u32 b) > } > #define mul_u32_u32 mul_u32_u32 > > +#define __div64_32 /* not needed */ This comment, *after* having read the commit message makes sense. When you look at it alone, after having opened the file, makes me scratch my head and wonder what is that thing supposed to mean. Please extend it. And put the comment ontop, not sideways. Thx.
On Tue, Aug 1, 2023, at 19:03, Borislav Petkov wrote: > On Tue, Jul 25, 2023 at 03:48:34PM +0200, Arnd Bergmann wrote: >> From: Arnd Bergmann <arnd@arndb.de> >> >> The __div64_32() function is provided for 32-bit architectures that >> don't have a custom do_div() implementation. x86_32 has one, and >> does not use the header file that declares the function prototype, >> so the definition causes a W=1 warning: >> >> lib/math/div64.c:31:32: error: no previous prototype for '__div64_32' [-Werror=missing-prototypes] >> >> Define an empty macro to prevent the function definition from getting >> built, which avoids the warning and saves a little .text space. >> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de> >> --- >> arch/x86/include/asm/div64.h | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h >> index b8f1dc0761e4b..9826d5fc12e34 100644 >> --- a/arch/x86/include/asm/div64.h >> +++ b/arch/x86/include/asm/div64.h >> @@ -71,6 +71,8 @@ static inline u64 mul_u32_u32(u32 a, u32 b) >> } >> #define mul_u32_u32 mul_u32_u32 >> >> +#define __div64_32 /* not needed */ > > This comment, *after* having read the commit message makes sense. > > When you look at it alone, after having opened the file, makes me > scratch my head and wonder what is that thing supposed to mean. Please > extend it. > > And put the comment ontop, not sideways. Right, makes sense. How about this version? --- a/arch/x86/include/asm/div64.h +++ b/arch/x86/include/asm/div64.h @@ -71,6 +71,11 @@ static inline u64 mul_u32_u32(u32 a, u32 b) } #define mul_u32_u32 mul_u32_u32 +/* + * __div64_32() is never called on x86, so prevent the + * generic definition from getting built. + */ +#define __div64_32 #else # include <asm-generic/div64.h> Arnd
On Tue, Aug 01, 2023 at 10:48:02PM +0200, Arnd Bergmann wrote: > Right, makes sense. How about this version? > > --- a/arch/x86/include/asm/div64.h > +++ b/arch/x86/include/asm/div64.h > @@ -71,6 +71,11 @@ static inline u64 mul_u32_u32(u32 a, u32 b) > } > #define mul_u32_u32 mul_u32_u32 > > +/* > + * __div64_32() is never called on x86, so prevent the > + * generic definition from getting built. > + */ > +#define __div64_32 > > #else > # include <asm-generic/div64.h> Yap. Thx.
On Wed, 2 Aug 2023, Borislav Petkov wrote: > > --- a/arch/x86/include/asm/div64.h > > +++ b/arch/x86/include/asm/div64.h > > @@ -71,6 +71,11 @@ static inline u64 mul_u32_u32(u32 a, u32 b) > > } > > #define mul_u32_u32 mul_u32_u32 > > > > +/* > > + * __div64_32() is never called on x86, so prevent the > > + * generic definition from getting built. > > + */ > > +#define __div64_32 > > > > #else > > # include <asm-generic/div64.h> > > Yap. Hmm, shouldn't this be something like: #define __div64_32(n, base) BUILD_BUG() instead? Otherwise you risk `__div64_32(n, base)' getting expanded to `(n, base)', if the macro does get called mistakenly for some reason, and the expansion is a valid expression which may not produce a warning even, depending on usage. Maciej
On Mon, Aug 07, 2023 at 09:37:00PM +0100, Maciej W. Rozycki wrote:
> Otherwise you risk `__div64_32(n, base)' getting expanded to `(n, base)',
You mean in the very obscure case of a 32-bit kernel where they don't call
do_div() but call this low level function?
I'd say if they can't be bothered to even grep the tree for the right usage,
they deserve both pieces... :)
On Mon, 7 Aug 2023, Borislav Petkov wrote: > On Mon, Aug 07, 2023 at 09:37:00PM +0100, Maciej W. Rozycki wrote: > > Otherwise you risk `__div64_32(n, base)' getting expanded to `(n, base)', > > You mean in the very obscure case of a 32-bit kernel where they don't call > do_div() but call this low level function? > > I'd say if they can't be bothered to even grep the tree for the right usage, > they deserve both pieces... :) Well, people do make mistakes and life is tough enough already, so why make it tougher when we can have a free sanity check? I mean there's hardly any cost from the extra characters added and it can save someone hassle with debugging, which is always tough by definition. I've suffered from silly mistakes myself on many occasions, possibly from being distracted in the middle of doing something, and while I figured things out eventually, it often cost me a day of effort or so wasted in chasing them. Maciej
diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h index b8f1dc0761e4b..9826d5fc12e34 100644 --- a/arch/x86/include/asm/div64.h +++ b/arch/x86/include/asm/div64.h @@ -71,6 +71,8 @@ static inline u64 mul_u32_u32(u32 a, u32 b) } #define mul_u32_u32 mul_u32_u32 +#define __div64_32 /* not needed */ + #else # include <asm-generic/div64.h>