Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
  • linux
  • scripts
  • checkpatch.pl
Find file BlameHistoryPermalink
  • Dwaipayan Ray's avatar
    checkpatch: fix multi-statement macro checks for while blocks. · 2e44e803
    Dwaipayan Ray authored Oct 15, 2020
    Checkpatch.pl doesn't have a check for excluding while (...) {...} blocks
    from MULTISTATEMENT_MACRO_USE_DO_WHILE error.
    
    For example, running checkpatch.pl on the file mm/maccess.c in the kernel
    generates the following error:
    
    ERROR: Macros with complex values should be enclosed in parentheses
    +#define copy_from_kernel_nofault_loop(dst, src, len, type, err_label)  \
    +       while (len >= sizeof(type)) {                                   \
    +               __get_kernel_nofault(dst, src, type, err_label);        \
    +               dst += sizeof(type);                                    \
    +               src += sizeof(type);                                    \
    +               len -= sizeof(type);                                    \
    +       }
    
    The error is misleading for this case.  Enclosing it in parentheses
    doesn't make any sense.
    
    Checkpatch already has an exception list for such common macro types.
    Added a new exception for while (...) {...} style blocks to the same.
    
    In addition, the brace flatten logic was modified by changing the
    substitution characters from "1" to "1u".  This was done to ensure that
    macros in the form "#define foo(bar) while(bar){bar--;}" were also
    correctly procecssed.
    
    Link: https://lore.kernel.org/linux-kernel-mentees/dc985938aa3986702815a0bd68dfca8a03c85447.camel@perches.com/
    
    
    
    Suggested-by: default avatarJoe Perches <joe@perches.com>
    Signed-off-by: default avatarDwaipayan Ray <dwaipayanray1@gmail.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Link: https://lkml.kernel.org/r/20201001171903.312021-1-dwaipayanray1@gmail.com
    
    
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    2e44e803
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7