Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp4127030pxm; Tue, 1 Mar 2022 11:49:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6D7NWiKzR/E0LJ3FeKjjd5KDDwn6lmy4AlPCMw3sfEOD+GZTKgPrKYk/4XI6pt/qN9e39 X-Received: by 2002:a17:906:b2c6:b0:6cf:e599:6b81 with SMTP id cf6-20020a170906b2c600b006cfe5996b81mr19860050ejb.578.1646164179521; Tue, 01 Mar 2022 11:49:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646164179; cv=none; d=google.com; s=arc-20160816; b=HkShK49PSE9tUKIvD0FO/zd5oDEB7kdeDPXwNmnJy1E2xroLXfYGBxvrumtQs8L1ez NupnvMsv9dYjuZpYMAp8yfV8FuCMxJs5qsJU6Mu734FIqB7CsZL7WFExbZYLcfUHzXZ9 TfNcGW0I8pg1jt0E0m+vFDHKH98uN4FZ1kGOA9yea9XHA/5xGP0pBvbc65Be5SpsxqF/ royat9/fragwi/E+wQWV4YFzHGZarOta7E9o9PlNA5dUafZsS8a7jdqYE/eY9ZJJtIii h8aZ2X1NEqaiGpelOzkqNx+EnxrSm9h9LBhMniJthUWfkSKxBdlgI952gnkxT1KmfwyU Tdzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=fEJmde6hyoUbayaLFPrUvAAzHbLAITUQ6aYMKbKXuMw=; b=vPDfsEeOUfPXRIQE86fQh8WjXxGNWxLo0Kw2j4+6L62JVY6lmQ0LAEKdN9+9h4ERnR XTV+buiDHIX+gJJWDsw8Z9dn6YVW61Zqs9iNCXFvKw/IDC4bAMFTSxJ1jc6nWzcI3NZP ve0zpPDlOsWsnoRx2Ow5jCVXj1OispqvogLVAeBXiNJm6ZOrU+D/lzXn4rgDbK+/38jD bnXYZ32992hUH8eAoKt5BXrB3vQbkQBgmR+0Fi+THfNZgXjUoph/p+d42VQVfcjnDVqh AVLWhEZNFwdr+J6M/EGFAlK6SC27tlOoc3CFlwQfiBk03aRsH4l6gGByqR5wBzUQiRa4 J3Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DAkNpCOl; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x29-20020a50d61d000000b00410b8506f14si9115225edi.605.2022.03.01.11.49.16; Tue, 01 Mar 2022 11:49:39 -0800 (PST) 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=DAkNpCOl; 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 S234277AbiCAQzR (ORCPT + 99 others); Tue, 1 Mar 2022 11:55:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232880AbiCAQzQ (ORCPT ); Tue, 1 Mar 2022 11:55:16 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DECE36321; Tue, 1 Mar 2022 08:54:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9ECEEB8184F; Tue, 1 Mar 2022 16:54:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 740C1C340EE; Tue, 1 Mar 2022 16:54:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646153672; bh=9NZHNm5f//UknLBQJi8aC7uw9czFahxKr+dcDCmFUCE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DAkNpCOltDdkG4CouhQG0dgkdaSG+j0l1C23qUMaLCvWXveml1Bg7Um3AS0uTmR33 Z6yOKIMrLwUHhvy7GfU7WOAEAtARrMJKtdVhHwmHcp7horUQosHtlsFQg5gqUan1XR d0UrTqoxcw3w/XKYLhEEWVhXQ7H8JYmTb7SDLzdNRBXWyJxPAlb+dnJgJnWL5npNeW 63xbWytUOsFzaJrkFx9qyR2Ew31u64F7qX9wHQeu3E2JtobC2y8ZxWIiMP3vYgRqh9 YRCHyXZxC8WdH460sGtTP9MnHQr6LhQQVgrUVnzWBfQKx4zeBp6yrIhS3qsDwpWV90 YFYdZxrdVrO4w== Date: Tue, 1 Mar 2022 09:54:26 -0700 From: Nathan Chancellor To: Arnd Bergmann Cc: Masahiro Yamada , Arnd Bergmann , Linus Torvalds , Marco Elver , Jani Nikula , David Sterba , Alex Shi , Nick Desaulniers , Miguel Ojeda , Mark Rutland , linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] treewide: use -Wdeclaration-after-statement Message-ID: References: <20220301145233.3689119-1-arnd@kernel.org> <20220301145233.3689119-2-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220301145233.3689119-2-arnd@kernel.org> X-Spam-Status: No, score=-7.5 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: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 01, 2022 at 03:52:32PM +0100, Arnd Bergmann wrote: > From: Mark Rutland > > In a subsequent patch we'll move the kernel from using `-std=gnu89` to > `-std=gnu11`, permitting the use of additional C11 features such as > for-loop initial declarations. > > One contentious aspect of C99 is that it permits mixed declarations and > code, and for now at least, it seems preferable to enforce that > declarations must come first. > > These warnings were already disabled in the kernel itself, but not > for KBUILD_USERCFLAGS or the compat VDSO on arch/arm64, which uses > a separate set of CFLAGS. > > This patch fixes an existing violation in modpost.c, which is not > reported because of the missing flag in KBUILD_USERCFLAGS: > > | scripts/mod/modpost.c: In function ‘match’: > | scripts/mod/modpost.c:837:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] > | 837 | const char *endp = p + strlen(p) - 1; > | | ^~~~~ > > Signed-off-by: Mark Rutland > [arnd: don't add a duplicate flag to the default set, update changelog] > Signed-off-by: Arnd Bergmann Reviewed-by: Nathan Chancellor > --- > Makefile | 3 ++- > arch/arm64/kernel/vdso32/Makefile | 1 + > scripts/mod/modpost.c | 4 +++- > 3 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/Makefile b/Makefile > index 94fa9a849a7a..37ef6a555dcd 100644 > --- a/Makefile > +++ b/Makefile > @@ -432,7 +432,8 @@ HOSTCXX = g++ > endif > > export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ > - -O2 -fomit-frame-pointer -std=gnu89 > + -O2 -fomit-frame-pointer -std=gnu89 \ > + -Wdeclaration-after-statement > export KBUILD_USERLDFLAGS := > > KBUILD_HOSTCFLAGS := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) > diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile > index 9378ea055bf2..ed181bedbffc 100644 > --- a/arch/arm64/kernel/vdso32/Makefile > +++ b/arch/arm64/kernel/vdso32/Makefile > @@ -68,6 +68,7 @@ VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ > -fno-strict-aliasing -fno-common \ > -Werror-implicit-function-declaration \ > -Wno-format-security \ > + -Wdeclaration-after-statement \ > -std=gnu11 > VDSO_CFLAGS += -O2 > # Some useful compiler-dependent flags from top-level Makefile > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > index 6bfa33217914..fe693304b120 100644 > --- a/scripts/mod/modpost.c > +++ b/scripts/mod/modpost.c > @@ -833,8 +833,10 @@ static int match(const char *sym, const char * const pat[]) > { > const char *p; > while (*pat) { > + const char *endp; > + > p = *pat++; > - const char *endp = p + strlen(p) - 1; > + endp = p + strlen(p) - 1; > > /* "*foo*" */ > if (*p == '*' && *endp == '*') { > -- > 2.29.2 > >