From patchwork Wed May 2 13:20:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 907533 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="TOMnR5oA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40bf6L4jdrz9rvt for ; Wed, 2 May 2018 23:20:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751440AbeEBNUj (ORCPT ); Wed, 2 May 2018 09:20:39 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:34859 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751076AbeEBNUh (ORCPT ); Wed, 2 May 2018 09:20:37 -0400 Received: by mail-wm0-f53.google.com with SMTP id o78so24414035wmg.0 for ; Wed, 02 May 2018 06:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=YMiesH4gReDenZzLUdKpnfrj+2uz+0TSKxkC6iKKSOE=; b=TOMnR5oA8l16jkCmq+7wwAQhTKcS2FrqK1qbuWBSrV4Cd9FMQtXtYDua1seXqo+VPS CsPYEurxGpwsfI5a/qAFi+v5Rco23Wib1LxkXNtu8KCiTUXLe59tiT2ewkRhiHyrTsGy JMnx9ldrOyJj8vp0PC/q5NkQrAkFFr2SUn56eMIp7otSjO+QtX2BsDQwO9UpFI5VEkdT FQBYMxtQ+HCRov23A1931HA0gyx3Kohnq9rj5NmICAqfXhSSLcyD4aNzUTDUPk/NzcBS pMYDqbuogc8k1XK/FkfgJXtFTWjHeiv9vco0qqjSlvg18mPXuYbtPQfsOmsznLmkorec kSLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YMiesH4gReDenZzLUdKpnfrj+2uz+0TSKxkC6iKKSOE=; b=Jx7xP0VZzTBmYyeR99eFoRzJG7z2tabxCB8+CsaLBs4Dxz25Nve83dlj3CgWZNIaK/ 7zMSiV/b6OmbvmCOrCx5VDNa0lniGrnnkGnQ0ihyUkwDEkI4MzDTlQQnwGnSGFsrd9R+ k8ntWfIrA+kCXkOe/XC7bR/K0odFM/TQ8YncSKAtW4BhNntzP4eGncCP28NwXQsm7hC4 j+tNC8ejw2k90sxXxSXh1Qj9nRsV58Gzr4EiotvpVHs66sO9GpPMDIcbP6V4CAYCn5uu tkkhGMvoaataBE8yQsg7jJLKt2Vw+H0Cb+MSCR0LEZFXhlPgoEHx9NRucDnMsABlROku zC0Q== X-Gm-Message-State: ALQs6tC9gSTh5/3ji2YDGcWN2COMMxDkuNZ0jrA3ebyu1W/zm9aawbTC +5CiMq27cslzF4d/tcsutQXmUg== X-Google-Smtp-Source: AB8JxZppaeoIduQid2owcnf05i+na/9atCQQ0wScw6QUay2qIVJwUgmDzQKcMn9DIRwJjdPpGziA8w== X-Received: by 2002:aa7:d287:: with SMTP id w7-v6mr25903438edq.53.1525267236353; Wed, 02 May 2018 06:20:36 -0700 (PDT) Received: from reblochon.netronome.com (host-79-78-33-110.static.as9105.net. [79.78.33.110]) by smtp.gmail.com with ESMTPSA id e29-v6sm6924865edd.45.2018.05.02.06.20.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 May 2018 06:20:35 -0700 (PDT) From: Quentin Monnet To: daniel@iogearbox.net, ast@kernel.org Cc: dsahern@gmail.com, yhs@fb.com, ecree@solarflare.com, netdev@vger.kernel.org, oss-drivers@netronome.com, quentin.monnet@netronome.com Subject: [PATCH bpf-next v2] bpf: relax constraints on formatting for eBPF helper documentation Date: Wed, 2 May 2018 14:20:24 +0100 Message-Id: <20180502132024.14550-1-quentin.monnet@netronome.com> X-Mailer: git-send-email 2.14.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The Python script used to parse and extract eBPF helpers documentation from include/uapi/linux/bpf.h expects a very specific formatting for the descriptions (single dot represents a space, '>' stands for a tab): /* ... *.int bpf_helper(list of arguments) *.> Description *.> > Start of description *.> > Another line of description *.> > And yet another line of description *.> Return *.> > 0 on success, or a negative error in case of failure ... */ This is too strict, and painful for developers who wants to add documentation for new helpers. Worse, it is extremely difficult to check that the formatting is correct during reviews. Change the format expected by the script and make it more flexible. The script now works whether or not the initial space (right after the star) is present, and accepts both tabs and white spaces (or a combination of both) for indenting description sections and contents. Concretely, something like the following would now be supported: /* ... *int bpf_helper(list of arguments) *......Description *.> > Start of description... *> > Another line of description *..............And yet another line of description *> Return *.> ........0 on success, or a negative error in case of failure ... */ While at it, remove unnecessary carets from each regex used with match() in the script. They are redundant, as match() tries to match from the beginning of the string by default. v2: Remove unnecessary caret when a regex is used with match(). Signed-off-by: Quentin Monnet --- scripts/bpf_helpers_doc.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/bpf_helpers_doc.py b/scripts/bpf_helpers_doc.py index 30ba0fee36e4..8f59897fbda1 100755 --- a/scripts/bpf_helpers_doc.py +++ b/scripts/bpf_helpers_doc.py @@ -39,9 +39,9 @@ class Helper(object): Break down helper function protocol into smaller chunks: return type, name, distincts arguments. """ - arg_re = re.compile('^((const )?(struct )?(\w+|...))( (\**)(\w+))?$') + arg_re = re.compile('((const )?(struct )?(\w+|...))( (\**)(\w+))?$') res = {} - proto_re = re.compile('^(.+) (\**)(\w+)\(((([^,]+)(, )?){1,5})\)$') + proto_re = re.compile('(.+) (\**)(\w+)\(((([^,]+)(, )?){1,5})\)$') capture = proto_re.match(self.proto) res['ret_type'] = capture.group(1) @@ -87,7 +87,7 @@ class HeaderParser(object): # - Same as above, with "const" and/or "struct" in front of type # - "..." (undefined number of arguments, for bpf_trace_printk()) # There is at least one term ("void"), and at most five arguments. - p = re.compile('^ \* ((.+) \**\w+\((((const )?(struct )?(\w+|\.\.\.)( \**\w+)?)(, )?){1,5}\))$') + p = re.compile(' \* ?((.+) \**\w+\((((const )?(struct )?(\w+|\.\.\.)( \**\w+)?)(, )?){1,5}\))$') capture = p.match(self.line) if not capture: raise NoHelperFound @@ -95,7 +95,7 @@ class HeaderParser(object): return capture.group(1) def parse_desc(self): - p = re.compile('^ \* \tDescription$') + p = re.compile(' \* ?(?:\t| {6,8})Description$') capture = p.match(self.line) if not capture: # Helper can have empty description and we might be parsing another @@ -109,7 +109,7 @@ class HeaderParser(object): if self.line == ' *\n': desc += '\n' else: - p = re.compile('^ \* \t\t(.*)') + p = re.compile(' \* ?(?:\t| {6,8})(?:\t| {8})(.*)') capture = p.match(self.line) if capture: desc += capture.group(1) + '\n' @@ -118,7 +118,7 @@ class HeaderParser(object): return desc def parse_ret(self): - p = re.compile('^ \* \tReturn$') + p = re.compile(' \* ?(?:\t| {6,8})Return$') capture = p.match(self.line) if not capture: # Helper can have empty retval and we might be parsing another @@ -132,7 +132,7 @@ class HeaderParser(object): if self.line == ' *\n': ret += '\n' else: - p = re.compile('^ \* \t\t(.*)') + p = re.compile(' \* ?(?:\t| {6,8})(?:\t| {8})(.*)') capture = p.match(self.line) if capture: ret += capture.group(1) + '\n'