kernel-doc: Strip #ifdef/#endif in enums
authorConchúr Navid <conchur@web.de>
Sun, 8 Nov 2015 09:48:05 +0000 (10:48 +0100)
committerJonathan Corbet <corbet@lwn.net>
Fri, 20 Nov 2015 23:13:48 +0000 (16:13 -0700)
Some enumerations in the kernel headers use #ifdef to reduce their size
based on the the configuration. These lines have to be stripped to avoid
parsing problems.

For example a simple input like

    /**
     * enum flags - test flags
     * @flag1: first flag
     * @flag2: second flag
     */
    enum flags {
     flag1 = BIT(0),
    #ifdef SECOND_FLAG
     flag2 = BIT(1),
    #endif
    };

resulted in parsing warnings like

    warning: Enum value '#ifdef SECOND_FLAG;flag2 = BIT(1)' not described in enum 'flags'
    warning: Enum value '#endif;' not described in enum 'flags'

Signed-off-by: Conchúr Navid <conchur@web.de>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
scripts/kernel-doc

index 8313b49b6cd0c196e61db5ad140c8a9d49a8a850..f5c2971244a39232256155b5d7a9cb3fb2042afb 100755 (executable)
@@ -1844,7 +1844,8 @@ sub dump_enum($$) {
     my $file = shift;
 
     $x =~ s@/\*.*?\*/@@gos;    # strip comments.
-    $x =~ s@#\s*define\s+[^;]*;@@gos; # strip #define macros inside enums
+    # strip #define macros inside enums
+    $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos;
 
     if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
        $declaration_name = $1;
This page took 0.025249 seconds and 5 git commands to generate.