From patchwork Fri Jun 9 08:46:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 105443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp807126vqr; Fri, 9 Jun 2023 02:01:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ69dWx2mzuhYn9oag9rOW0D1w4MW2vCrPrPIiBnACmtoMcuiW4zbAcoC+hA0HNoYf+nj8I4 X-Received: by 2002:a05:6a00:17a5:b0:64c:b45f:fc86 with SMTP id s37-20020a056a0017a500b0064cb45ffc86mr646292pfg.17.1686301295821; Fri, 09 Jun 2023 02:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686301295; cv=none; d=google.com; s=arc-20160816; b=J5uWh1wYdS8RcDaisbnQg/bn9fbvqcbUZOHfCPcKDZ4OudWY82+zWj3hMwBW6an8eX dV0ycCIMtryYRLy+CH90AE4+gcAg8zQzY9Q21xgVNO4OcIbtJkeCLjVy4JZnekOQcw++ LdQdcy0+176sEVdp1k/g4rd9fFEfEnJKnj+6A0U7w8cy9cVznam7FWxI1Ls6ziDNaIHg u35q/yBeTGd00RGFax2iErtt+hAMn7UtLzsQjg+dstFIemzwRIQ6Z4nyLsPo8XeLkMnH G1O8MDop0K7UXzi/PYXJ9mzYk41n9i/4Ve7px3qM3GLSo8enOCqEE/xHxFygcDgUlfRb IoUA== 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=rYsZ7NUM9QnsnZDvOA2XVbvmpJGN8lxYjvG/P+i1FWY=; b=pXjEiiHXvrF4VUwkkKbxd6mKiCGJrQjgYL+njD/6uA9tKL6mE2cR3hM/Ivk6TKBTLl imEUCQwLjDuemJ1/1rRMedqHyS15sWW2cviUUUp01biyFFPJrTgo+y4xRWBlyum8/li2 hbpw9uqlXqNlhQGFLoQzYP4sK2CsJjy4Z7YubOXqlZoINs4GI1mGOxzDkX3IsyayzTQh VhskrU9kLmYIZeNxtkBh6M/7n5uD4R8zqFOsZ7CP15bhhtQUTIp3IycLX6WTriV5PjP4 cBeOJ8+42gnU7fMsgG+PhNBhfpBo/ALEq/RImhPqmOT57yWKAml0DE4D9EmNn4jEqh8t doWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=HqA2KMqs; 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=REJECT dis=NONE) header.from=sipsolutions.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv186-20020a632ec3000000b00545276c46e7si1118956pgb.624.2023.06.09.02.01.14; Fri, 09 Jun 2023 02:01:35 -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=@sipsolutions.net header.s=mail header.b=HqA2KMqs; 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=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240002AbjFIIq6 (ORCPT + 99 others); Fri, 9 Jun 2023 04:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239153AbjFIIqy (ORCPT ); Fri, 9 Jun 2023 04:46:54 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 962471730; Fri, 9 Jun 2023 01:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=rYsZ7NUM9QnsnZDvOA2XVbvmpJGN8lxYjvG/P+i1FWY=; t=1686300408; x=1687510008; b=HqA2KMqsn9ICFDaWj4YroeLzOFnG0XLVJeQiIglFG9YZAwT7CreIyStCebg+ylxuZcCE5/zCLpr gy4rdI+WZc01zd5d8rN+6JiN33VruWNL4oiIEo1paR9WxOFUouKKl8pIfpF1Gx5sJ32qCB1/hGj5Q WxuvUC9ls050/93+6jGhhsIRhvgD04qhOdtsVfM+KwTnia2x5PlY/RkUDgNGyGPusk5p6eovVsmzY LIKRsXi7icdf+fCJ0BhMkii0www8oJsmNBKRGwKNGIveZIOTRO/piu/VxhIX92EpENLhAZLPLbGod gSn9PAMs8cR91ErEj7Ld7QERZWyDF2YpB3nQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1q7Xld-000seH-1T; Fri, 09 Jun 2023 10:46:45 +0200 From: Johannes Berg To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org Cc: Johannes Berg Subject: [PATCH v3 1/2] kernel-doc: don't let V=1 change outcome Date: Fri, 9 Jun 2023 10:46:41 +0200 Message-Id: <20230609104642.0a5f030f59a5.I21ab3b54eeebd638676bead3b2f87417944e44f3@changeid> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767945432442369372?= X-GMAIL-MSGID: =?utf-8?q?1768215067597916756?= From: Johannes Berg The kernel-doc script currently reports a number of issues only in "verbose" mode, but that's initialized from V=1 (via KBUILD_VERBOSE), so if you use KDOC_WERROR=1 then adding V=1 might actually break the build. This is rather unexpected. Change kernel-doc to not change its behaviour wrt. errors (or warnings) when verbose mode is enabled, but rather add separate warning flags (and -Wall) for it. Allow enabling those flags via environment/make variables in the kernel's build system for easier user use, but to not have to parse them in the script itself. Signed-off-by: Johannes Berg --- v2: - parse environment variables in build system rather than the script itself, as suggested by Masahiro Yamada - fix indentation v3: - use a single KDOCFLAGS variable --- Documentation/kbuild/kbuild.rst | 6 ++++++ scripts/Makefile.build | 2 +- scripts/kernel-doc | 28 +++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst index 2a22ddb1b848..bd906407e307 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -150,6 +150,12 @@ the UTS_MACHINE variable, and on some architectures also the kernel config. The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian architecture. +KDOCFLAGS +--------- +Specify extra (warning/error) flags for kernel-doc checks during the build, +see scripts/kernel-doc for which flags are supported. Note that this doesn't +(currently) apply to documentation builds. + ARCH ---- Set ARCH to the architecture to be built. diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 9f94fc83f086..a0b4fb58201c 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -101,7 +101,7 @@ else ifeq ($(KBUILD_CHECKSRC),2) endif ifneq ($(KBUILD_EXTRA_WARN),) - cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< + cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $(KDOCFLAGS) $< endif # Compile C sources (.c) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 2486689ffc7b..8f8440870a0f 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -23,7 +23,7 @@ kernel-doc - Print formatted kernel documentation to stdout =head1 SYNOPSIS - kernel-doc [-h] [-v] [-Werror] + kernel-doc [-h] [-v] [-Werror] [-Wall] [-Wreturn] [-Wshort-description] [-Wcontents-before-sections] [ -man | -rst [-sphinx-version VERSION] [-enable-lineno] | -none @@ -133,6 +133,9 @@ my $dohighlight = ""; my $verbose = 0; my $Werror = 0; +my $Wreturn = 0; +my $Wshort_desc = 0; +my $Wcontents_before_sections = 0; my $output_mode = "rst"; my $output_preformatted = 0; my $no_doc_sections = 0; @@ -187,9 +190,14 @@ if (defined($ENV{'KCFLAGS'})) { } } +# reading this variable is for backwards compat just in case +# someone was calling it with the variable from outside the +# kernel's build system if (defined($ENV{'KDOC_WERROR'})) { $Werror = "$ENV{'KDOC_WERROR'}"; } +# other environment variables are converted to command-line +# arguments in cmd_checkdoc in the build system # Generated docbook code is inserted in a template at a point where # docbook v3.1 requires a non-zero sequence of RefEntry's; see: @@ -318,6 +326,16 @@ while ($ARGV[0] =~ m/^--?(.*)/) { $verbose = 1; } elsif ($cmd eq "Werror") { $Werror = 1; + } elsif ($cmd eq "Wreturn") { + $Wreturn = 1; + } elsif ($cmd eq "Wshort-desc") { + $Wshort_desc = 1; + } elsif ($cmd eq "Wcontents-before-sections") { + $Wcontents_before_sections = 1; + } elsif ($cmd eq "Wall") { + $Wreturn = 1; + $Wshort_desc = 1; + $Wcontents_before_sections = 1; } elsif (($cmd eq "h") || ($cmd eq "help")) { pod2usage(-exitval => 0, -verbose => 2); } elsif ($cmd eq 'no-doc-sections') { @@ -1748,9 +1766,9 @@ sub dump_function($$) { # This check emits a lot of warnings at the moment, because many # functions don't have a 'Return' doc section. So until the number # of warnings goes sufficiently down, the check is only performed in - # verbose mode. + # -Wreturn mode. # TODO: always perform the check. - if ($verbose && !$noret) { + if ($Wreturn && !$noret) { check_return_section($file, $declaration_name, $return_type); } @@ -2054,7 +2072,7 @@ sub process_name($$) { $state = STATE_NORMAL; } - if (($declaration_purpose eq "") && $verbose) { + if (($declaration_purpose eq "") && $Wshort_desc) { emit_warning("${file}:$.", "missing initial short description on line:\n$_"); } @@ -2103,7 +2121,7 @@ sub process_body($$) { } if (($contents ne "") && ($contents ne "\n")) { - if (!$in_doc_sect && $verbose) { + if (!$in_doc_sect && $Wcontents_before_sections) { emit_warning("${file}:$.", "contents before sections\n"); } dump_section($file, $section, $contents); From patchwork Fri Jun 9 08:46:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 105436 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp804114vqr; Fri, 9 Jun 2023 01:54:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6uDosJNyOR9MezfemVgXQcynufhMi4Zoz1R3Rkeo68l/oOsqhH1kfcaYqg37mG/Wmnizcw X-Received: by 2002:a05:6a20:2445:b0:113:d42c:a909 with SMTP id t5-20020a056a20244500b00113d42ca909mr1446408pzc.6.1686300880314; Fri, 09 Jun 2023 01:54:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686300880; cv=none; d=google.com; s=arc-20160816; b=QfO2xNcq7doCwp1r+SsiW5d0uboZ2FcYzA7k6rQzBK0g9XSG+NL4/0rLqxARofnPMf Ky2V1ecvWZpMYclueBRB/8P40Gp088yX1Bq2QLY71Fkm0SBH2wQ/rx9iJvgBgJo2srO7 YvhvPTbx/xbsPgI1cO5Cu9Islj6CK+SfM7bsrURrZ2iAb9rsk8MAsDdinQm9/yU57gnO IS64X5xNK4b7bIUyfoj6BCv7yCeAwcWKT6jhaiMXNHEzPRIQRi6NzQK3u1L83UteOj6w uHI5ejRHkQhivhWHBNVcscTeL3JMRiFW9CBX9dAF2OQ39OtUVSzenRDl7rOuJnETvqmU IozA== 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=8c8LFaF/+nfjR8FUn1SGTVmbBSqzu+xt6KI9vgP+uZQ=; b=J18kn/ZHG7DLno1ikzqFTGVrILVTjLa7X/OVYIqxKimu0NSEnjXXRffja5xkgafk4u tEpxZ3qYRTI1Eo/MfHalLeTMQwdKERi9Vk1IQWJ7/9n691HuFbCZSj27Voc5W6622rJt ix2FyL9720rvpoTbm1RIk8p8xaC9tWyOXnA9wXnjB4VAzjJ0Z6ll7pCqyzxpLNbdk8f4 2KEr1grzTfFxW2sU7mEaTJi+Ah2Pn4bP+noSD/v4BCIXeZO9QQuVC95DTxFjZu5du2Fw 5lnN915hh6VoiqcAQJYRYTBRK5vA0epxqRdaXrtkvNykkJsBaj/WGwZHLw/FkQ3PdTro DwSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=CvKa8vYe; 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=REJECT dis=NONE) header.from=sipsolutions.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t24-20020a63b258000000b0053ff2b60a1esi2307856pgo.874.2023.06.09.01.54.25; Fri, 09 Jun 2023 01:54:40 -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=@sipsolutions.net header.s=mail header.b=CvKa8vYe; 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=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238268AbjFIIqz (ORCPT + 99 others); Fri, 9 Jun 2023 04:46:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238515AbjFIIqx (ORCPT ); Fri, 9 Jun 2023 04:46:53 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D32F0E47; Fri, 9 Jun 2023 01:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=8c8LFaF/+nfjR8FUn1SGTVmbBSqzu+xt6KI9vgP+uZQ=; t=1686300408; x=1687510008; b=CvKa8vYe+22wXjpUl/Gyv7C2id9YYbYIlQlfkpEqQzSnL7B hnH9kKeKkj7zp68MoHo7D+2IHyZne2BECJy7/BCSGUdiKIQBKRS4yM0wnbd/rA3bVU3mmKilRvmEX 0lziAhzVb2cP+pGyAOqSAF06WuuIBOWg7RJPxLKegSK+v/l7AIU1zzdA4DQTXu4MkKhys3wNmAs9T JhN/QXnP5QFlbnOHLK1ummdEP3xOkbU5ox8jazQuG9DHjaQwVeKUc9McIUPRYw8yHGOyxMRUrPPSd DzpQQQQtrD5EfxmR8zUNWQ15oMGIJg7nzrMZIVchY0pfivMrgUavXAi/34BlEiPw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1q7Xle-000seH-03; Fri, 09 Jun 2023 10:46:46 +0200 From: Johannes Berg To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org Cc: Johannes Berg Subject: [PATCH v3 2/2] kbuild: enable kernel-doc -Wall for W=2 Date: Fri, 9 Jun 2023 10:46:42 +0200 Message-Id: <20230609104642.170be0ce1cf2.Ibd08cad396b630b68d93b2469905ad55b375af65@changeid> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609104642.0a5f030f59a5.I21ab3b54eeebd638676bead3b2f87417944e44f3@changeid> References: <20230609104642.0a5f030f59a5.I21ab3b54eeebd638676bead3b2f87417944e44f3@changeid> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768214631662883067?= X-GMAIL-MSGID: =?utf-8?q?1768214631662883067?= From: Johannes Berg For W=2, we can enable more kernel-doc warnings, such as missing return value descriptions etc. Signed-off-by: Johannes Berg --- scripts/Makefile.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a0b4fb58201c..ddd644bd032d 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -101,7 +101,9 @@ else ifeq ($(KBUILD_CHECKSRC),2) endif ifneq ($(KBUILD_EXTRA_WARN),) - cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $(KDOCFLAGS) $< + cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $(KDOCFLAGS) \ + $(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \ + $< endif # Compile C sources (.c)