From patchwork Tue Sep 19 02:34:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randy Dunlap X-Patchwork-Id: 141805 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3268277vqi; Tue, 19 Sep 2023 03:24:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9Tm4AecUZulB5881Zpiw419Ppgtdh1CeDHlgs56uTGrLCr26CurvzUZvQeLV04NHWZaBA X-Received: by 2002:a17:90b:f86:b0:268:15dd:c5c7 with SMTP id ft6-20020a17090b0f8600b0026815ddc5c7mr7952347pjb.40.1695119092327; Tue, 19 Sep 2023 03:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695119092; cv=none; d=google.com; s=arc-20160816; b=Ipaln1E9zuhpk9TGEim+jXDgoooMfPkG9/EtCgV7YbEkujMWObkusdgkkkNi55jD4s 4ylIuNgdczEIySy+bf5YDGC/V2/fkoi7a0XZ8aUJihZuvoGp+DvF0dLXpaIMIMxb9jyt Zar88pjNKVQFwN8WQTJzQaZ80tEDsjzw6DYu+Z9a9+sxiIhqX/VXr12KI475plNBvtVt 0BsKvzJSgUM6cD9EJdQG3SBJ8hzDLJ3J7LNWS/prNrU5VCJBzqXQFc6ku5HD7x8l7Z0N th8oDTO3OeDbjjnaBWi1EwJmJcu+q/4GcMh+bcxMoYVsNICQ/0MCg+anHMHkI0a4Otq0 tB1A== 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=g4yHT/YRAYrqNY9hH0+amE5WopD9orBCNU9KXQeS03E=; fh=Gt5JS598BYSpTXO95MfIQFb7GsHjBSuareMMdhO+8I8=; b=s9bx37+nQbktGAVrJdJCOD09EKJ384G7fUYwSrwKO5bbz8iSCakLk21QuuYOiQvYA+ Ssz3GutcyQARU4cOQkBTT4CNYAHtTqGNpdsxvqWtGgBoeb41S13h+wekHGdWTguXMI0V xVcd+q33KIBy1PZRt4Ou2vRCgsgjrh7lbCkC6CLmRHLROnGP8KS6ncrsZ9CmtzO5ZV2X ZYQmg8t/yiGg311O7pGICHViByqW5hLmR3hJf8HwYC2hEcFOQDp6rDaCy/plvaEC76Mi gRoizKy7CBgCUVWyGAQEimMih8WJqCj6kOAJxRljGqVQyI372Tn/M8YwOcN7qY8mm3sa uelQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=KXXPBJYD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ne10-20020a17090b374a00b00262ebe643a2si9339467pjb.186.2023.09.19.03.24.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 03:24:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=KXXPBJYD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E452E81352A8; Mon, 18 Sep 2023 19:34:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbjISCeZ (ORCPT + 26 others); Mon, 18 Sep 2023 22:34:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbjISCeY (ORCPT ); Mon, 18 Sep 2023 22:34:24 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DB0B10A; Mon, 18 Sep 2023 19:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=g4yHT/YRAYrqNY9hH0+amE5WopD9orBCNU9KXQeS03E=; b=KXXPBJYD2OeLsndzhVEyDOnj4u GEMZcaIX1K6hbPQ39hrAurScrQ+MGWwM/tbFdq7X73OFiBf944r7nw3UnTtaQGfNpqXVjHKhQcVex Qc0sm12sL2IRECBjeRUK9OkOYj+tRtdgIebtyoN30ArbiV4Q7IcIztRyOu+la43W4vV3cpz1KLf0f Do7FWLz9TBJrAgBiZO4fVTwKma6GyKIBszYHYE4lQIhw0Sm5a4mflgmePsZ8hrLliI1afVvTSVcsR boul1fjJH2VOgxa8QmQryTEZA8nQzYj6yXwOeR6aE8IA3hL6Y/NjICEpkqZ8SxirUlhFLP9Yqq0Fg MdwT1bZg==; Received: from [2601:1c2:980:9ec0::9fed] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qiQZ7-00GjPy-03; Tue, 19 Sep 2023 02:34:17 +0000 From: Randy Dunlap To: linux-kernel@vger.kernel.org Cc: Randy Dunlap , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH] kernel-doc: add a warning prefix option Date: Mon, 18 Sep 2023 19:34:15 -0700 Message-ID: <20230919023415.4744-1-rdunlap@infradead.org> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 19:34:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777445218309032994 X-GMAIL-MSGID: 1777461197405524793 Add an environment variable ("KDOC_LABEL") for use by scripts/kernel-doc. This variable instructs kernel-doc to label each "warning:" line with a prefix of the KDOC_LABEL value. E.g., using KDOC_LABEL="doc" ./scripts/kernel-doc -none -Wall kernel/panic.c causes kernel-doc warnings to be emitted as "doc warning:", like this: kernel/panic.c:497: doc warning: No description found for return value of 'print_tainted' This can aid either in finding or eliminating kernel-doc warnings. 'sparse' does something similar to this, although it uses a command line option (-fdiagnostic-prefix[=prefix]). Signed-off-by: Randy Dunlap Cc: Jonathan Corbet Cc: linux-doc@vger.kernel.org --- scripts/kernel-doc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff -- a/scripts/kernel-doc b/scripts/kernel-doc --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -127,6 +127,7 @@ if ($#ARGV == -1) { } my $kernelversion; +my $line_label; my ($sphinx_major, $sphinx_minor, $sphinx_patch); my $dohighlight = ""; @@ -439,6 +440,16 @@ sub get_kernel_version() { return $version; } +# get line label from env +sub get_line_label() { + my $label = ''; + + if (defined($ENV{'KDOC_LABEL'})) { + $label = $ENV{'KDOC_LABEL'} . " "; + } + return $label; +} + # sub print_lineno { my $lineno = shift; @@ -450,7 +461,7 @@ sub print_lineno { sub emit_warning { my $location = shift; my $msg = shift; - print STDERR "$location: warning: $msg"; + print STDERR "$location: ${line_label}warning: $msg"; ++$warnings; } ## @@ -2360,6 +2371,8 @@ if ($output_mode eq "rst") { $kernelversion = get_kernel_version(); +$line_label = get_line_label(); + # generate a sequence of code that will splice in highlighting information # using the s// operator. for (my $k = 0; $k < @highlights; $k++) {