Skip to content

Commit

Permalink
kernel-doc: Strip #ifdef/#endif in enums
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jonathan Corbet <[email protected]>
  • Loading branch information
Conchúr Navid authored and Jonathan Corbet committed Nov 20, 2015
1 parent 8a9260a commit 4468e21
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/kernel-doc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4468e21

Please sign in to comment.