[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 02/32] kernel-doc: fix processing nested structs with attribut
From: |
Paolo Bonzini |
Subject: |
[PATCH v2 02/32] kernel-doc: fix processing nested structs with attributes |
Date: |
Tue, 1 Dec 2020 05:34:32 -0500 |
From: André Almeida <andrealmeid@collabora.com>
The current regular expression for strip attributes of structs (and
for nested ones as well) also removes all whitespaces that may
surround the attribute. After that, the code will split structs and
iterate for each symbol separated by comma at the end of struct
definition (e.g. "} alias1, alias2;"). However, if the nested struct
does not have any alias and has an attribute, it will result in a
empty string at the closing bracket (e.g "};"). This will make the
split return nothing and $newmember will keep uninitialized. Fix
that, by ensuring that the attribute substitution will leave at least
one whitespace.
Signed-off-by: André Almeida <andrealmeid@collabora.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-2-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
scripts/kernel-doc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 4fbaaa05e3..d6bdb77ceb 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1103,10 +1103,10 @@ sub dump_struct($$) {
# strip comments:
$members =~ s/\/\*.*?\*\///gos;
# strip attributes
- $members =~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)//gi;
- $members =~ s/\s*__aligned\s*\([^;]*\)//gos;
- $members =~ s/\s*__packed\s*//gos;
- $members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos;
+ $members =~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)/ /gi;
+ $members =~ s/\s*__aligned\s*\([^;]*\)/ /gos;
+ $members =~ s/\s*__packed\s*/ /gos;
+ $members =~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos;
# replace DECLARE_BITMAP
$members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long
$1\[BITS_TO_LONGS($2)\]/gos;
# replace DECLARE_HASHTABLE
--
2.26.2
- [PATCH v2 05/32] scripts: kernel-doc: proper handle @foo->bar(), (continued)
- [PATCH v2 05/32] scripts: kernel-doc: proper handle @foo->bar(), Paolo Bonzini, 2020/12/01
- [PATCH v2 06/32] scripts: kernel-doc: accept negation like !@var, Paolo Bonzini, 2020/12/01
- [PATCH v2 04/32] scripts/kernel-doc: Add support for named variable macro arguments, Paolo Bonzini, 2020/12/01
- [PATCH v2 09/32] scripts/kernel-doc: parse __ETHTOOL_DECLARE_LINK_MODE_MASK, Paolo Bonzini, 2020/12/01
- [PATCH v2 08/32] Replace HTTP links with HTTPS ones: documentation, Paolo Bonzini, 2020/12/01
- [PATCH v2 14/32] scripts: kernel-doc: add support for typedef enum, Paolo Bonzini, 2020/12/01
- [PATCH v2 07/32] scripts: kernel-doc: accept blank lines on parameter description, Paolo Bonzini, 2020/12/01
- [PATCH v2 15/32] Revert "scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments", Paolo Bonzini, 2020/12/01
- [PATCH v2 10/32] scripts/kernel-doc: handle function pointer prototypes, Paolo Bonzini, 2020/12/01
- [PATCH v2 11/32] scripts/kernel-doc: optionally treat warnings as errors, Paolo Bonzini, 2020/12/01
- [PATCH v2 02/32] kernel-doc: fix processing nested structs with attributes,
Paolo Bonzini <=
- [PATCH v2 16/32] Revert "kernel-doc: Use c:struct for Sphinx 3.0 and later", Paolo Bonzini, 2020/12/01
- [PATCH v2 26/32] Revert "kernel-doc: Handle function typedefs without asterisks", Paolo Bonzini, 2020/12/01
- [PATCH v2 19/32] scripts: kernel-doc: fix troubles with line counts, Paolo Bonzini, 2020/12/01
- [PATCH v2 20/32] scripts: kernel-doc: reimplement -nofunction argument, Paolo Bonzini, 2020/12/01
- [PATCH v2 25/32] scripts: kernel-doc: try to use c:function if possible, Paolo Bonzini, 2020/12/01
- [PATCH v2 12/32] kernel-doc: include line numbers for function prototypes, Paolo Bonzini, 2020/12/01
- [PATCH v2 29/32] scripts: kernel-doc: split typedef complex regex, Paolo Bonzini, 2020/12/01
- [PATCH v2 13/32] kernel-doc: add support for ____cacheline_aligned attribute, Paolo Bonzini, 2020/12/01
- [PATCH v2 24/32] scripts: kernel-doc: fix line number handling, Paolo Bonzini, 2020/12/01
- [PATCH v2 23/32] scripts: kernel-doc: allow passing desired Sphinx C domain dialect, Paolo Bonzini, 2020/12/01