All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Linux Doc Mailing List <linux-doc@vger.kernel.org>,
	Jonathan Corbet <corbet@lwn.net>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v5 09/52] scripts: kernel-doc: don't mangle with parameter list
Date: Tue,  6 Oct 2020 16:03:06 +0200	[thread overview]
Message-ID: <933d25d383d0976693ad80dcdacd68077a456db8.1601992016.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1601992016.git.mchehab+huawei@kernel.org>

While kernel-doc needs to parse parameters in order to
identify its name, it shouldn't be touching the type,
as parsing it is very difficult, and errors happen.

One current error is when parsing this parameter:

	const u32 (*tab)[256]

Found at ./lib/crc32.c, on this function:

	u32 __pure crc32_be_generic (u32 crc, unsigned char const *p, size_t len, const u32 (*tab)[256], u32 polynomial);

The current logic mangles it, producing this output:

	const u32 ( *tab

That's something that it is not recognizeable.

So, instead, let's push the argument as-is, and use it
when printing the function prototype and when describing
each argument.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 scripts/kernel-doc | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 33ad3ce66f73..09e3e78b9723 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -655,10 +655,10 @@ sub output_function_man(%) {
 	$type = $args{'parametertypes'}{$parameter};
 	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
 	    # pointer-to-function
-	    print ".BI \"" . $parenth . $1 . "\" " . $parameter . " \") (" . $2 . ")" . $post . "\"\n";
+	    print ".BI \"" . $parenth . $1 . "\" " . " \") (" . $2 . ")" . $post . "\"\n";
 	} else {
 	    $type =~ s/([^\*])$/$1 /;
-	    print ".BI \"" . $parenth . $type . "\" " . $parameter . " \"" . $post . "\"\n";
+	    print ".BI \"" . $parenth . $type . "\" " . " \"" . $post . "\"\n";
 	}
 	$count++;
 	$parenth = "";
@@ -929,7 +929,7 @@ sub output_function_rst(%) {
 	    # pointer-to-function
 	    print $1 . $parameter . ") (" . $2 . ")";
 	} else {
-	    print $type . " " . $parameter;
+	    print $type;
 	}
     }
     if ($args{'typedef'}) {
@@ -954,7 +954,7 @@ sub output_function_rst(%) {
 	$type = $args{'parametertypes'}{$parameter};
 
 	if ($type ne "") {
-	    print "``$type $parameter``\n";
+	    print "``$type``\n";
 	} else {
 	    print "``$parameter``\n";
 	}
@@ -1479,7 +1479,7 @@ sub create_parameterlist($$$$) {
 	    # Treat preprocessor directive as a typeless variable just to fill
 	    # corresponding data structures "correctly". Catch it later in
 	    # output_* subs.
-	    push_parameter($arg, "", $file);
+	    push_parameter($arg, "", "", $file);
 	} elsif ($arg =~ m/\(.+\)\s*\(/) {
 	    # pointer-to-function
 	    $arg =~ tr/#/,/;
@@ -1488,7 +1488,7 @@ sub create_parameterlist($$$$) {
 	    $type = $arg;
 	    $type =~ s/([^\(]+\(\*?)\s*$param/$1/;
 	    save_struct_actual($param);
-	    push_parameter($param, $type, $file, $declaration_name);
+	    push_parameter($param, $type, $arg, $file, $declaration_name);
 	} elsif ($arg) {
 	    $arg =~ s/\s*:\s*/:/g;
 	    $arg =~ s/\s*\[/\[/g;
@@ -1513,26 +1513,28 @@ sub create_parameterlist($$$$) {
 	    foreach $param (@args) {
 		if ($param =~ m/^(\*+)\s*(.*)/) {
 		    save_struct_actual($2);
-		    push_parameter($2, "$type $1", $file, $declaration_name);
+
+		    push_parameter($2, "$type $1", $arg, $file, $declaration_name);
 		}
 		elsif ($param =~ m/(.*?):(\d+)/) {
 		    if ($type ne "") { # skip unnamed bit-fields
 			save_struct_actual($1);
-			push_parameter($1, "$type:$2", $file, $declaration_name)
+			push_parameter($1, "$type:$2", $arg, $file, $declaration_name)
 		    }
 		}
 		else {
 		    save_struct_actual($param);
-		    push_parameter($param, $type, $file, $declaration_name);
+		    push_parameter($param, $type, $arg, $file, $declaration_name);
 		}
 	    }
 	}
     }
 }
 
-sub push_parameter($$$$) {
+sub push_parameter($$$$$) {
 	my $param = shift;
 	my $type = shift;
+	my $org_arg = shift;
 	my $file = shift;
 	my $declaration_name = shift;
 
@@ -1596,8 +1598,8 @@ sub push_parameter($$$$) {
 	# "[blah" in a parameter string;
 	###$param =~ s/\s*//g;
 	push @parameterlist, $param;
-	$type =~ s/\s\s+/ /g;
-	$parametertypes{$param} = $type;
+	$org_arg =~ s/\s\s+/ /g;
+	$parametertypes{$param} = $org_arg;
 }
 
 sub check_sections($$$$$) {
-- 
2.26.2


  parent reply	other threads:[~2020-10-06 14:03 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-06 14:02 [PATCH v5 00/52] Fix html build with Sphinx 3.1 and above Mauro Carvalho Chehab
2020-10-06 14:02 ` [PATCH v5 01/52] docs: cdomain.py: add support for a new Sphinx 3.1+ tag Mauro Carvalho Chehab
2020-10-06 14:02 ` [PATCH v5 02/52] docs: cdomain.py: extend it to handle new Sphinx 3.x tags Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 03/52] docs: conf.py: disable automarkup for Sphinx 3.x Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 04/52] scripts: kernel-doc: make it more compatible with " Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 05/52] scripts: kernel-doc: use a less pedantic markup for funcs on " Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 06/52] scripts: kernel-doc: fix troubles with line counts Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 07/52] scripts: kernel-doc: reimplement -nofunction argument Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 08/52] scripts: kernel-doc: fix typedef identification Mauro Carvalho Chehab
2020-10-06 14:03 ` Mauro Carvalho Chehab [this message]
2020-10-06 14:03 ` [PATCH v5 10/52] scripts: kernel-doc: allow passing desired Sphinx C domain dialect Mauro Carvalho Chehab
2020-10-06 21:18   ` kernel test robot
2020-10-06 21:18     ` kernel test robot
2020-10-12 12:33   ` [PATCH v5.1 " Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 11/52] docs: kerneldoc.py: append the name of the parsed doc file Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 12/52] docs: kerneldoc.py: add support for kerneldoc -nosymbol Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 13/52] media: docs: make CEC documents compatible with Sphinx 3.1+ Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 14/52] media: docs: make V4L documents more " Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 15/52] media: docs: make DVB " Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 16/52] media: docs: make MC " Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 17/52] media: docs: make RC " Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 18/52] media: cec-core.rst: don't use c:type for structs Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 19/52] math64.h: kernel-docs: Convert some markups into normal comments Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 20/52] memblock: get rid of a :c:type leftover Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 21/52] docs: remove some replace macros like |struct foo| Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 22/52] docs: get rid of :c:type explicit declarations for structs Mauro Carvalho Chehab
2020-10-06 14:03   ` Mauro Carvalho Chehab
2020-10-06 16:41   ` Greg Kroah-Hartman
2020-10-06 16:41     ` Greg Kroah-Hartman
2020-10-06 14:03 ` [PATCH v5 23/52] docs: trace-uses.rst: remove bogus c-domain tags Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 24/52] docs: it_IT: fix namespace collisions at locking.rst Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 25/52] docs: net: ieee802154.rst: fix C expressions Mauro Carvalho Chehab
2020-10-06 14:13   ` Stefan Schmidt
2020-10-06 14:14   ` Stefan Schmidt
2020-10-06 14:03 ` [PATCH v5 26/52] docs: genericirq.rst: don't document chip.c functions twice Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 27/52] docs: kernel-api.rst: drop kernel/irq/manage.c kernel-doc tag Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 28/52] docs: remove sound API duplication Mauro Carvalho Chehab
2020-10-06 14:03   ` Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 29/52] docs: basics.rst: move kernel-doc workqueue markups to workqueue.rst Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 30/52] docs: scsi: target.rst: remove iSCSI transport class kernel-doc markup Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 31/52] docs: device_link.rst: remove duplicated kernel-doc include Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 32/52] docs: basics.rst: get rid of rcu kernel-doc macros Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 33/52] docs: net: statistics.rst: remove a duplicated kernel-doc Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 34/52] docs: pstore-blk.rst: fix kernel-doc tags Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 35/52] docs: fs: fscrypt.rst: get rid of :c:type: tags Mauro Carvalho Chehab
2020-10-06 19:19   ` Eric Biggers
2020-10-14  7:12     ` Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 36/52] docs: devices.rst: get rid of :c:type macros Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 37/52] docs: sound: writing-an-alsa-driver.rst: get rid of :c:type Mauro Carvalho Chehab
2020-10-06 14:03   ` Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 38/52] docs: block: blk-mq.rst: " Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 39/52] docs: writing-an-alsa-driver.rst: fix some bad c:func: markups Mauro Carvalho Chehab
2020-10-06 14:03   ` Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 40/52] docs: fpga: replace :c:member: macros Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 41/52] docs: kgdb.rst: fix :c:type: usages Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 42/52] docs: libata.rst: fix a wrong usage of :c:type: tag Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 43/52] docs: infrastructure.rst: don't include firmware kernel-doc Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 44/52] docs: gpu: i915.rst: Fix several C duplication warnings Mauro Carvalho Chehab
2020-10-06 14:03   ` [Intel-gfx] " Mauro Carvalho Chehab
2020-10-06 14:03   ` Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 45/52] docs: devices.rst: fix a C reference markup Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 46/52] docs: it_IT: hacking.rst: fix a typo on a markup Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 47/52] docs: mei.rst: fix a C expression markup Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 48/52] docs: basics.rst: avoid duplicated C function declaration Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 49/52] workqueue: fix a kernel-doc warning Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 50/52] scripts: kernel-doc: try to use c:function if possible Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 51/52] docs: conf.py: fix c:function support with Sphinx 3.x Mauro Carvalho Chehab
2020-10-06 14:03 ` [PATCH v5 52/52] docs: conf.py: change the Sphinx 3.x+ text Mauro Carvalho Chehab
2020-10-06 16:56 ` [PATCH v5 00/52] Fix html build with Sphinx 3.1 and above Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=933d25d383d0976693ad80dcdacd68077a456db8.1601992016.git.mchehab+huawei@kernel.org \
    --to=mchehab+huawei@kernel.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.