Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp235116rdb; Thu, 19 Oct 2023 03:01:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHImRJmstdECD4AQg0w4EKtBq0jXZ06pdCndV9gkf9D95e1Io9ZUuI3B9aPaHMxX+f7JgTI X-Received: by 2002:a05:6870:9123:b0:1ea:9898:c07f with SMTP id o35-20020a056870912300b001ea9898c07fmr1993101oae.22.1697709703249; Thu, 19 Oct 2023 03:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697709703; cv=none; d=google.com; s=arc-20160816; b=QibAU3RyK9CjZayFjcSD/u8tJhmpAv9X5uI8yrfp5ZhSsU6nj/C8Auw5JLAhIk8bza UU5s6STCW5eBhx4atKz0yLHLkan3C+tx8s0WU7g7jEg+4NRutX2uxDe4Tke7P7RLVzfH Ngef5GQ+G1EPVEPDaODkQTc+o7MJ5in/ZlrJjAEjs6nDT4QNQq8ujU4DCntZzsvThevY Sst7euIFujrLwzZn02WSDyN/7uXdSmMz5MjE+tyzjKIvPKvaMUyVMQ4Vr1LckgkdATNZ QpSQvtcHtb+dKToo1Z5AnFMoJzcLdHTffSZ4ZlvpVL590QH6trQnrU2oe35KcNuUfSDv Cw5A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=KnYJiwAEqt9xdR4UP+cbRbO8xH5LfMdQmvPm1qx+DZU=; fh=IuXsrPOdrciaxFAC2SvYjRgBdYdnG1766rYTEQGgYZw=; b=RGnsUmk+WjjyYt0ZoS0jl4BfQzjxI9dxOxyOgavPRmuQ22YtNoQJItZxrfkgxkK0Y2 p/1eZQbUB6EFQFJSlRSFdKOleabEPiXAtPqOztsuU2f03MX/4C51QAj8A03qKUbwdSvs SqOuPmClFcWeL+KrIaKv6a+Ijlp2lu9Kbwf9rNrZKsjp/wNJGnnTqwVT+4EnZeQQpuAF U2uHdtBGU3WK+wKLw/DYapkV8B6VyIWG303CkAJ2Di1fTjAq2qY0jWuqYWBJlevXbJcm Br47cNZ4m+5PR2QKY9L53z2GQLNAqMYAEclHc1vOyfZvrKaY4lc70mTjAmewRAf1fhUn MFQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=D1HDPY72; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id u17-20020a656711000000b0059f0cebd052si4011454pgf.436.2023.10.19.03.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 03:01:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=D1HDPY72; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 69BF88263762; Thu, 19 Oct 2023 03:01:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345104AbjJSKB3 (ORCPT + 99 others); Thu, 19 Oct 2023 06:01:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345039AbjJSKB1 (ORCPT ); Thu, 19 Oct 2023 06:01:27 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24BFBB8; Thu, 19 Oct 2023 03:01:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697709685; x=1729245685; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=4tVLPdmGhD/Ev5x1gsJNSKEuLw82S1fRviVzD2Ftcyw=; b=D1HDPY72iNb7NauR/lyBdW/6a6MPCJT/XQSpDL7WuBFhAdX2/hk9QU4J 76h95Jaz1KSWjQ0T5EMCa2u7hbGKIPT0SDyGtRSCNqmOGcW4Nz2JCVwnl QWoHOJlS0+zW2BHffKpFZY+BfmafLCpq91GBqTFJA3vyGeuL/LPhAUSjK nO7tR9bd/9ucVjVqkz/A/1wSSrUimh6DXrvGooWyeUEY6fxgvAI9zqxKQ 0CZ7Gd5wsEtoDJDHxSQi5TGAV6Yqmw64AamnZvu8UWQsvJmt0A29Oh3Mz aQbPobowsAeVPWvznV/QLAXAXVhb1JhIFR8bGkoml1Qe7+HG4bxqZY7Hz g==; X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="371278642" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="371278642" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 03:01:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="733512273" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="733512273" Received: from yujie-x299.sh.intel.com ([10.239.159.77]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 03:01:22 -0700 From: Yujie Liu To: linux-doc@vger.kernel.org Cc: Yujie Liu , Jonathan Corbet , linux-kernel@vger.kernel.org, Pierre-Louis Bossart , Randy Dunlap Subject: [PATCH] scripts/kernel-doc: match -Werror flag strictly Date: Thu, 19 Oct 2023 17:56:37 +0800 Message-Id: <20231019095637.2471840-1-yujie.liu@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 03:01:40 -0700 (PDT) In our CI testing, we use some commands as below to only turn a specific type of warnings into errors, but we notice that kernel-doc warnings are also turned into errors unexpectedly. $ make KCFLAGS="-Werror=return-type" W=1 kernel/fork.o kernel/fork.c:1406: warning: Function parameter or member 'mm' not described in 'set_mm_exe_file' kernel/fork.c:1406: warning: Function parameter or member 'new_exe_file' not described in 'set_mm_exe_file' kernel/fork.c:1441: warning: Function parameter or member 'mm' not described in 'replace_mm_exe_file' kernel/fork.c:1441: warning: Function parameter or member 'new_exe_file' not described in 'replace_mm_exe_file' kernel/fork.c:1491: warning: Function parameter or member 'mm' not described in 'get_mm_exe_file' kernel/fork.c:1510: warning: Function parameter or member 'task' not described in 'get_task_exe_file' kernel/fork.c:1534: warning: Function parameter or member 'task' not described in 'get_task_mm' kernel/fork.c:2109: warning: bad line: kernel/fork.c:2130: warning: Function parameter or member 'ret' not described in '__pidfd_prepare' kernel/fork.c:2130: warning: Excess function parameter 'pidfd' description in '__pidfd_prepare' kernel/fork.c:2179: warning: Function parameter or member 'ret' not described in 'pidfd_prepare' kernel/fork.c:2179: warning: Excess function parameter 'pidfd' description in 'pidfd_prepare' kernel/fork.c:3195: warning: expecting prototype for clone3(). Prototype was for sys_clone3() instead 13 warnings as Errors make[3]: *** [scripts/Makefile.build:243: kernel/fork.o] Error 13 make[3]: *** Deleting file 'kernel/fork.o' make[2]: *** [scripts/Makefile.build:480: kernel] Error 2 make[1]: *** [/root/linux/Makefile:1913: .] Error 2 make: *** [Makefile:234: __sub-make] Error 2 From the git history, commit 2c12c8103d8f ("scripts/kernel-doc: optionally treat warnings as errors") introduces a new command-line option to make kernel-doc warnings into errors. It can also read the KCFLAGS environment variable to decide whether to turn this option on, but the regex used for matching may not be accurate enough. It can match both "-Werror" and "-Werror=", so the option is turned on by mistake in the latter case. Fix this by strictly matching the flag "-Werror": there must be a space or start of string in the front, and a space or end of string at the end. This can handle all the following cases correctly: KCFLAGS="-Werror" make W=1 [MATCH] KCFLAGS="-Werror=return-type" make W=1 [NO MATCH] KCFLAGS="-Wcomment -Werror -Wundef" make W=1 [MATCH] KCFLAGS="-Wcomment -Werror=return-type -Wundef" make W=1 [NO MATCH] Fixes: 2c12c8103d8f ("scripts/kernel-doc: optionally treat warnings as errors") Signed-off-by: Yujie Liu --- scripts/kernel-doc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 6e199a745ccb..d660e1f4b483 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -185,7 +185,7 @@ if (defined($ENV{'KBUILD_VERBOSE'}) && $ENV{'KBUILD_VERBOSE'} =~ '1') { if (defined($ENV{'KCFLAGS'})) { my $kcflags = "$ENV{'KCFLAGS'}"; - if ($kcflags =~ /Werror/) { + if ($kcflags =~ /(?<=^|\s)-Werror(?=$|\s)/) { $Werror = 1; } } -- 2.34.1