Skip to content
  • Matthijs Kooijman's avatar
    checkpatch: only warn for empty lines before closing braces by themselves · 74c8f433
    Matthijs Kooijman authored
    
    
    This check was intended to catch extra newlines at the end of a function
    definition, but it would trigger on any closing brace, including those
    of inline functions and macro definitions, triggering false positives.
    Now, only closing braces on a line by themselves trigger this check.
    
    Tested with:
    
    $ cat test.h
    /* test.h - Test file */
    
    static inline int foo(void) { return 0; }
    
    static inline int bar(void)
    {
            return 1;
    
    }
    
    $ ./scripts/checkpatch.pl --strict -f test.h # Before this commit
    CHECK: Blank lines aren't necessary before a close brace '}'
    +
    +static inline int foo(void) { return 0; }
    
    CHECK: Blank lines aren't necessary before a close brace '}'
    +
    +}
    
    total: 0 errors, 0 warnings, 2 checks, 9 lines checked
    
    $ ./scripts/checkpatch.pl --strict -f test.h # After this commit
    CHECK: Blank lines aren't necessary before a close brace '}'
    +
    +}
    
    total: 0 errors, 0 warnings, 1 checks, 9 lines checked
    
    Signed-off-by: default avatarMatthijs Kooijman <matthijs@stdin.nl>
    Cc: Andy Whitcroft <apw@canonical.com>
    Acked-by: default avatarJoe Perches <joe@perches.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    74c8f433