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
  • drivers
  • input
  • touchscreen.c
Find file BlameHistoryPermalink
  • Nathan Chancellor's avatar
    Input: touchscreen - avoid bitwise vs logical OR warning · a02dcde5
    Nathan Chancellor authored Oct 15, 2021
    
    
    A new warning in clang points out a few places in this driver where a
    bitwise OR is being used with boolean types:
    
    drivers/input/touchscreen.c:81:17: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]
            data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x",
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    This use of a bitwise OR is intentional, as bitwise operations do not
    short circuit, which allows all the calls to touchscreen_get_prop_u32()
    to happen so that the last parameter is initialized while coalescing the
    results of the calls to make a decision after they are all evaluated.
    
    To make this clearer to the compiler, use the '|=' operator to assign
    the result of each touchscreen_get_prop_u32() call to data_present,
    which keeps the meaning of the code the same but makes it obvious that
    every one of these calls is expected to happen.
    
    Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
    Reported-by: default avatarNick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
    Link: https://lore.kernel.org/r/20211014205757.3474635-1-nathan@kernel.org
    
    
    Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
    a02dcde5
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7