From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756183AbdABPWh (ORCPT ); Mon, 2 Jan 2017 10:22:37 -0500 Received: from mail-wj0-f195.google.com ([209.85.210.195]:36214 "EHLO mail-wj0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756139AbdABPWc (ORCPT ); Mon, 2 Jan 2017 10:22:32 -0500 From: Paolo Bonzini To: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: corbet@lwn.net Subject: [PATCH 2/5] kernel-doc: strip attributes even if they have an argument Date: Mon, 2 Jan 2017 16:22:24 +0100 Message-Id: <20170102152227.9446-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170102152227.9446-1-pbonzini@redhat.com> References: <20170102152227.9446-1-pbonzini@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An inline function can have an attribute, as in include/linux/log2.h, and kernel-doc handles this already for simple cases. However, some attributes have arguments (e.g. the "target" attribute). Handle those too. Furthermore, attributes could be at the beginning of a function declaration, before the return type. To correctly handle this case, you need to strip spaces after the attributes; otherwise, dump_function is left confused. Signed-off-by: Paolo Bonzini --- scripts/kernel-doc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index c1ea91c2e497..265ea16cbe22 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -2506,7 +2506,13 @@ sub dump_function($$) { $prototype =~ s/__must_check +//; $prototype =~ s/__weak +//; my $define = $prototype =~ s/^#\s*define\s+//; #ak added - $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; + $prototype =~ s/__attribute__\s*\(\( + (?: + [\w\s]++ # attribute name + (?:\([^)]*+\))? # attribute arguments + \s*+,? # optional comma at the end + )+ + \)\)\s+//x; # Yes, this truly is vile. We are looking for: # 1. Return type (may be nothing if we're looking at a macro) -- 2.9.3