Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp200508pxm; Fri, 25 Feb 2022 06:31:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGzQlKeLCRI43H9cUU8Y8t19qeAbvb2bqBgq/+VZ6fNHZDjLRP7+jvmxmB9qvzhxFUItEz X-Received: by 2002:aa7:c7c4:0:b0:407:52cc:3b32 with SMTP id o4-20020aa7c7c4000000b0040752cc3b32mr7333331eds.397.1645799503680; Fri, 25 Feb 2022 06:31:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645799503; cv=none; d=google.com; s=arc-20160816; b=Yq0mEujuOUV1Vy3xdB8yZ/dVcfH/HO6oas0LhEi8YG5oYnrhGwOLLy4lpyEDAo+vPP nXJaDX+LsJ81UvCbGn4BwjRvwjOgR9d1y806jWePqzpdg66QafzoVuDQIRZTKf56xh60 XTjkvmquGL21/eqXrBCmrGu9t0d6mZxf81BZzftl6eIUpV+Er+gLjmtLDr13Mkk78qWY l0oqq4Gl4ixowEC8cYuJ+zQsOX6e+jsuLwzIazUzwrbsCRBxAjHtHhsucZGnBS1LzoMZ f4lfHtsScD/EDysb6/aclgfFTEuAszCNjm/+bJP6Bjj56hy0jfx/rxWha2csynDJG1CH wITA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=Oosgf26C3cGHE1QmDHmqfOUEe/LnMdne4rGI4/p7qq4=; b=KsfrYr2R9FglUEcVfrqXVPN8G5QIR9idEy5GRlTO2Nf3I6NgEBpsH5SeBMKZ+qIWA+ W+A3JexlVXdU+skW7ntLg0P7hb4FsjgOiXmQMOjKENOI3UqDRSS6xobK+cMycEe6qecZ X6n3M6OirzfVTzT1gjVql6TQmvB+5vw5/Bb1auynqOsWafgZ+fUvPh1DuhPZ7TFzLn21 IExCaaevzUMmRNPYPHDMnWoPnFJF3CCe3/XFMjSpn7AVxNMVw+0Ogr4IjuH/mqIl106T DOy3zHRyq+2kxgJVriOk5gfwR5wCoVQcF3/KAiyiR68brn6Of114kG4l1eaMwqxS8XZg 0P6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YoadWNid; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kg1-20020a17090776e100b006d0824b2f4dsi1446787ejc.1006.2022.02.25.06.31.19; Fri, 25 Feb 2022 06:31:43 -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=@gmail.com header.s=20210112 header.b=YoadWNid; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238426AbiBYIQk (ORCPT + 99 others); Fri, 25 Feb 2022 03:16:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237887AbiBYIQi (ORCPT ); Fri, 25 Feb 2022 03:16:38 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C2C31E521D for ; Fri, 25 Feb 2022 00:16:02 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id p9so3185567wra.12 for ; Fri, 25 Feb 2022 00:16:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=Oosgf26C3cGHE1QmDHmqfOUEe/LnMdne4rGI4/p7qq4=; b=YoadWNid8jrZuAzwwdpw8uG9NG0tyExSz3wtZMAC9oPbW+TF/itAlD+mBY7HWhXpKq DmeLW3lwfIse5GB2zEHUcCcCPU0Rg3Xu3PRnkigkzFI4BA5nWpyI25WibbFVZ4acbEls CaYPblLYAAl7pfme5JpVS581S0xl8UvivnlRxcjnzEXWiRRktAtEw9CHxsnGeGnHLJLw e+HyTwqv0uFkA9NXiD1HQzyYiwonSIqilYm7iYItx36ESZP+Ou2XQOkuzsDOWYsor7JG AO76dheLPSufcWwVUS1D1MgUwRqqlioGp2bYL40gCXfMiFR/Cbisivx9G9/LdMpi41rh HITw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=Oosgf26C3cGHE1QmDHmqfOUEe/LnMdne4rGI4/p7qq4=; b=678nvGDsIsAK2ExUBeJmHuy91pjDZaRNHYVTvjRp+JYoScus//K4F9uAWRRCm3RbcM FDNaK9QPaNgVHM4bT20eqrwlfb71NDXPgV11sdltPFWHbPz2XNnQv3q3h1HN6cZeXd9r V7EB6tEWmUR1zX7rZsvgEXfEJ7AnmlHm8oPz9BYkRqsuNytYab09YCMPvF/faraURyxt SaAMLL3xeeNsuMo6178t3rKmVgNiHblU8k8PU8fTnE+nrFC200px7WI18CCnjByLs77V ZzDigguRRKhNaf4zoz2hAothLSNB3U4VkopEpGMr2dz0XdASbIboF3ZwmbWTbK0KTPl1 swIA== X-Gm-Message-State: AOAM532GiB9xFyYLAZHW5ivPRy6TaYI+JH2McPD0mPKYihj+NpVGaJ5y bizOZatzPBMvLzdgKrZauBw3FRAwmQ== X-Received: by 2002:a5d:64ea:0:b0:1ea:8148:6b97 with SMTP id g10-20020a5d64ea000000b001ea81486b97mr4966505wri.679.1645776961086; Fri, 25 Feb 2022 00:16:01 -0800 (PST) Received: from localhost.localdomain ([46.53.249.135]) by smtp.gmail.com with ESMTPSA id m17-20020a05600c4f5100b003810030c23fsm1852488wmq.40.2022.02.25.00.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 00:16:00 -0800 (PST) Date: Fri, 25 Feb 2022 11:15:58 +0300 From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] Drop -Wdeclaration-after-statement Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 Putting declarations before statement is relict of single pass compiler era. It was necessary to allocate stack slots before generating code. Recently added static_assert() is a declaration. -Wdeclaration-after-statement prevents its placement anywhere in the code for no reason. Placing variable declarations in the beginning of the block increases variable "LOC lifetime" so to speak and chances that it will be misused. This is very low probability bug but still. Declaring variables right before first use will make "LOC lifetime" smaller. { int x; [x is misused due to a typo] f(x); // first correct use } vs { [can't misuse undeclared variable] int x; f(x); // first correct use } Signed-off-by: Alexey Dobriyan --- Makefile | 3 --- arch/arm64/kernel/vdso32/Makefile | 1 - tools/power/acpi/Makefile.config | 1 - tools/power/cpupower/Makefile | 1 - tools/scripts/Makefile.include | 1 - 5 files changed, 7 deletions(-) --- a/Makefile +++ b/Makefile @@ -933,9 +933,6 @@ endif # arch Makefile may override CC so keep this after arch Makefile is included NOSTDINC_FLAGS += -nostdinc -# warn about C99 declaration after statement -KBUILD_CFLAGS += -Wdeclaration-after-statement - # Variable Length Arrays (VLAs) should not be used anywhere in the kernel KBUILD_CFLAGS += -Wvla --- a/arch/arm64/kernel/vdso32/Makefile +++ b/arch/arm64/kernel/vdso32/Makefile @@ -71,7 +71,6 @@ VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -std=gnu89 VDSO_CFLAGS += -O2 # Some useful compiler-dependent flags from top-level Makefile -VDSO_CFLAGS += $(call cc32-option,-Wdeclaration-after-statement,) VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign) VDSO_CFLAGS += -fno-strict-overflow VDSO_CFLAGS += $(call cc32-option,-Werror=strict-prototypes) --- a/tools/power/acpi/Makefile.config +++ b/tools/power/acpi/Makefile.config @@ -63,7 +63,6 @@ OPTIMIZATION := $(call cc-supports,-Os,-O2) WARNINGS := -Wall WARNINGS += $(call cc-supports,-Wstrict-prototypes) -WARNINGS += $(call cc-supports,-Wdeclaration-after-statement) KERNEL_INCLUDE := $(OUTPUT)include ACPICA_INCLUDE := $(srctree)/../../../drivers/acpi/acpica --- a/tools/power/cpupower/Makefile +++ b/tools/power/cpupower/Makefile @@ -118,7 +118,6 @@ OPTIMIZATION := $(call cc-supports,-Os,-O2) WARNINGS := -Wall -Wchar-subscripts -Wpointer-arith -Wsign-compare WARNINGS += $(call cc-supports,-Wno-pointer-sign) -WARNINGS += $(call cc-supports,-Wdeclaration-after-statement) WARNINGS += -Wshadow override CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \ --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -21,7 +21,6 @@ endif # Include saner warnings here, which can catch bugs: # EXTRA_WARNINGS := -Wbad-function-cast -EXTRA_WARNINGS += -Wdeclaration-after-statement EXTRA_WARNINGS += -Wformat-security EXTRA_WARNINGS += -Wformat-y2k EXTRA_WARNINGS += -Winit-self