• A
    regmap: avoid -Wint-in-bool-context warning · 1b0c22e4
    Arnd Bergmann 提交于
    When we pass the result of a multiplication as the timeout or the delay,
    we can get a warning from gcc-7:
    
    drivers/mmc/host/bcm2835.c:596:149: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
    drivers/mfd/arizona-core.c:247:195: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
    drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c:49:27: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
    
    The warning is a bit questionable inside of a macro, but this is
    intentional on the side of the gcc developers.  It is also an indication
    of another problem: we evaluate the timeout and sleep arguments multiple
    times, which can have undesired side-effects when those are complex
    expressions.
    
    This changes the two regmap variants to use local variables for storing
    copies of the timeouts.  This adds some more type safety, and avoids both
    the double-evaluation and the gcc warning.
    
    Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81484
    Link: http://lkml.kernel.org/r/20170726133756.2161367-1-arnd@arndb.deSigned-off-by: NArnd Bergmann <arnd@arndb.de>
    Signed-off-by: NMark Brown <broonie@kernel.org>
    1b0c22e4
regmap.h 42.2 KB