Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4571851pxk; Wed, 30 Sep 2020 06:32:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjwuYg2xNNbUyx1H5zjam1n0Nf14ra/F0ydufvgFy3Ny5l3io3FjoGMqUz+nrOp82Zzv3a X-Received: by 2002:a17:906:2618:: with SMTP id h24mr2697780ejc.198.1601472755184; Wed, 30 Sep 2020 06:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601472755; cv=none; d=google.com; s=arc-20160816; b=0y98gNoHhXRtOAKtYJJabvJZQSAcJALHUc23h4L2q1Caz4w8ZAZjLCgCZbSnDS03Ch nRQEJUU8GLkvEp/5EYHCdYVg5hluUQf9HO6R1hPllyXQ6PPnA9D1uyKvS0ODi5K7eJVN i0vbn/XpbjAsIeEjOm+2NxItIQST8SKlQd1t78w6AE45hHq+jlPXIiqVysVUIowmkHfC 697aciTsD877QgyEOpygRC9TgIzjhmcnw6AB8/3uPgG8JANVKI4oeNZD0yuDph1eBqT1 nb8nM7FTpPy4egvjFGG3P52sumaUJbtNvVhs8rJWQYJPx44HaCAMbk1Mgz9QE2ASLXVR Am2g== 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=NsTis/sPGC+7+NNxsXAa653NOC0rQJ1qI3nVwRRgndU=; b=EeXMlRwV+0n+8pFUEs8si1HQ4EOaf4UU48AwS6NwNWOjp+X+wl7ex8VfuV8VUXjVKJ gUJ0EpHJlXgc2Cw4+GbUcK0b/K0rPrLNfEBKBbKuEVUGcj0iSS5VP/hcBDrJFjRAJQ8x RV4HY++awBssg28x47+jH3HKxFtcAcckglsVUexxgN3Lw8+TiAvYtJZYWClCrwlv5nxN oXznLs7KhMT7XBK9iZRC2Q8Be5fUpszP4ggYZTCkn4g6FF/7Bd/2qYl2C+2arxKk0/qb SkyMzU/KjSZBA1GTf72WvIgqFdVy4DaAyXvh3kLGkbvEYaAsYbb4WfFlFRvpgoC0CZGN gscw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FWF0j2dn; 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 dd15si1018680edb.394.2020.09.30.06.32.12; Wed, 30 Sep 2020 06:32:35 -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=FWF0j2dn; 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 S1730806AbgI3N2Y (ORCPT + 99 others); Wed, 30 Sep 2020 09:28:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:38752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730104AbgI3NZV (ORCPT ); Wed, 30 Sep 2020 09:25:21 -0400 Received: from mail.kernel.org (ip5f5ad5c4.dynamic.kabel-deutschland.de [95.90.213.196]) (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 CC9522085B; Wed, 30 Sep 2020 13:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601472320; bh=0+EnP3ZDT+KyhPuJqAeV8ARJRg4AwySdCsA/hCoxFaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FWF0j2dndVvWbHwfw9+pgQI2o3ygiMwAtVE7Xj0Jp5FEkxTZyiyfbRZd0aI1BxSSL G7SQPdipCr017pjyVThLeh/rcLfPl6qw3nFbJpwlkeb++RfyT/qmeB9vYAsoaN4rur 1MTrZOHUYdJN+ZfhjYIENZsp1U/rjGh0pK62sNEs= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1kNc6f-001XJB-Qu; Wed, 30 Sep 2020 15:25:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v4 09/52] scripts: kernel-doc: don't mangle with parameter list Date: Wed, 30 Sep 2020 15:24:32 +0200 Message-Id: <7fcbd109b395c0f31031257a52dcd508850e15a6.1601467849.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: 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 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 --- scripts/kernel-doc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index a0344c78c641..f549837d874d 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"; } @@ -1472,7 +1472,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/#/,/; @@ -1481,7 +1481,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; @@ -1506,26 +1506,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; @@ -1589,8 +1591,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