Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp217784pxu; Tue, 6 Oct 2020 04:57:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+1W7yCgoBn2PZ9KCTl61C8Nw6OvuxNkevABuheSQ6Zm48hb2sR4bes8PpZp+WdOcLU5vL X-Received: by 2002:a17:906:e0cb:: with SMTP id gl11mr4781270ejb.486.1601985453828; Tue, 06 Oct 2020 04:57:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601985453; cv=none; d=google.com; s=arc-20160816; b=1Co2z7+IwM0sEQBc1W8cYQSaTCjKMPZ4Vm2GycjdJswl2/FD3j36ISKoNMp5+9pXkk MMEnCHPQbWKpB8YC7+R2x+iUNfv2S0JjKXEV2qKbI3+8kvgxSa917bRRsS3eRdFN3QDC 0F1hTj4hl7dN4PIFK9QGKQiNfMGYQUd48AeS417uZVYORhhhXdoZ8wwlamQIUExbZ5E8 wfmY315deRXraNkr+oFcxLWQ6w2834m9nt51YAJOtT+e8FAMsICkREgpVDn2JuedTIwQ qvTMNUCblPVg5hGWS9mR6o5EGzF8o7ihHI5VqgF6LMehCTnyZ1NnNqbKfQvOi136QyJC cyRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ULeDiKu+X7FT2uetdSOD98wLAG86MDW7UOsBHuZYACk=; b=s0ekg3nrAIkfQdyugPsT2WOOS5XNzOp+HTyT0Z8K8qVAuH9Tlw7LLkusmS0e36avAL gvanHkPOiuCI2hFshUzrHGcyRTEOw+BMfoJ87uAXnD1EaRp9jsVzSLV5GR1LwXDQ6LYq uuaqgsYTVLdx3umB70autmOhrEj0qExqr04bq+vd4aiS1dErQSjvHGS8JsSgkntaP+30 tlHprCmoZKAaf3VszfK+5DgeHHonV0okPcsfuoiloIZNeFF74uuujd7x8UUQvDqd+k5z /Y637kvK63n7H49zXgh8WGg4Vtjs+ma2SYDz9+Q/mrXrDbgk4N7/gGHKJAgQf0YyQIr3 hVSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D5yyin2N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si2246854ede.8.2020.10.06.04.57.09; Tue, 06 Oct 2020 04:57:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D5yyin2N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726232AbgJFLxl (ORCPT + 99 others); Tue, 6 Oct 2020 07:53:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:48006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbgJFLxk (ORCPT ); Tue, 6 Oct 2020 07:53:40 -0400 Received: from mail.kernel.org (ip5f5ad5bd.dynamic.kabel-deutschland.de [95.90.213.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 864AD2080A; Tue, 6 Oct 2020 11:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601985219; bh=xj3DKmTx+xt1aiabZV+/vLYvUVuonNKpv+Ct1aH1EHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D5yyin2NOr4oSD50jB8ARYD+XBa8anpaThKEZxh48wy4EEVp4KVAutI6fdGCZeM+N LCb8S6HQ8plDyG7JYeaYYVkxgIGlN1hu1hiMow2opK9csBI39ul7UR4qX53KH23X+Z 9/OMvCv2SusraPLjD1pwXSWLIFl9dWS7e0X1I/us= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1kPlXF-0015t5-2w; Tue, 06 Oct 2020 13:53:37 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Matthew Wilcox" , linux-kernel@vger.kernel.org Subject: [PATCH RFC] script: add a script for checking doc problems with external functions Date: Tue, 6 Oct 2020 13:53:34 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201005125920.27a7768d@coco.lan> References: <20201005125920.27a7768d@coco.lan> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While not all EXPORT_SYMBOL*() symbols should be documented, it seems useful to have a tool which would help to check what symbols aren't documented. This is a first step on this direction. The tool has some limitations. Yet, it could be useful for maintainers to check about missing documents on their subsystems. Suggested-by: Matthew Wilcox Signed-off-by: Mauro Carvalho Chehab --- scripts/check_docs_external_symbols | 127 ++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100755 scripts/check_docs_external_symbols diff --git a/scripts/check_docs_external_symbols b/scripts/check_docs_external_symbols new file mode 100755 index 000000000000..cc12562e6cd6 --- /dev/null +++ b/scripts/check_docs_external_symbols @@ -0,0 +1,127 @@ +#!/usr/bin/perl +# SPDX-License-Identifier: GPL-2.0 + +# +# Copyright (c) 2020, Huawei Tech. Co., Ltd. +# Author: Mauro Carvalho Chehab + +use warnings; +use strict; +use File::Find; + +sub check_file($) { + my $file = shift; + my (@files, @exports, @doc, @doc_refs); + my $content = "\n"; + + return 0 if (!($file =~ /\.[ch]$/)); + + my $dir = $file; + $dir =~ s,[^\/]+$,,; + + open IN, $file or return 0; + while () { + push @exports, $1 if (m/^EXPORT_SYMBOL.*\(\s*(\S+)\s*\)/); + + if (m/^\s*#\s*include\s+[\<](\S+)[\>]/) { + if (-e "include/$1") { + push @files, "include/$1"; + } else { + # Currently, can't check if include is elsewhere + return 0; + } + } + if (m/^\s*#\s*include\s+[\"](\S+)[\"]/) { + if (-e "$dir/$1") { + push @files, "$dir/$1"; + } else { + # Currently, can't check if include is elsewhere + return 0; + } + } + $content .= $_; + } + close IN; + + return 0 if ($content eq "\n"); + + + push @files, $file; + for (my $i = 0; $i < scalar(@files); $i++) { + $doc_refs[$i] = 0; + $doc[$i] = qx(./scripts/kernel-doc --sphinx-version 3.2.1 $files[$i] 2>/dev/null); + } + + my @missing_exports; + my $found = -1; + foreach my $e (@exports) { + # Check if the symbol is a function + if (!($content =~ (m/\n\s*(?:\w+\s+){0,}\*?\s*\b\Q$e\E\b\s*\(/))) { + next; + } + for (my $i = 0; $i < scalar(@files); $i++) { + if ($doc[$i] =~ m/\b\Q$e\E\b/) { + $found = $i; + $doc_refs[$i]++; + last; + } + } + + push @missing_exports, $e if ($found < 0); + } + + if (@missing_exports) { + print "warning: $file: missing documentation for @missing_exports\n"; + } + + for (my $i = 0; $i < scalar(@files); $i++) { + next if (!$doc_refs[$i]); + my $includes = qx(git grep -l "kernel-doc::\\s*$files[$i]" Documentation/); + + printf "warning: %s: file not included at Documentation/\n", $files[$i] if ($includes eq ""); + } + return 1; +} + +sub parse_dir { + check_file $File::Find::name; +} + +# +# main +# + +my $file; + +if (@ARGV) { + while (@ARGV) { + my $file = shift; + + if (-d $file) { + find({wanted => \&parse_dir, no_chdir => 1}, $file); + } else { + check_file $file; + } + } + exit; +} else { + my @files = qx(git grep -l EXPORT_SYMBOL); + foreach $file (@files) { + $file =~ s/\s+$//; + check_file $file; + } +} -- 2.26.2