On Thu, Jun 30, 2022 at 09:59:33AM -0400, Alexander Aring wrote: > This patch adds the __cond_lock() macro to refcounts conditional lock > API. Currently sparse cannot detect the conditional lock handling of > refcount_dec_and_lock() functionality and prints a context imbalance > warning like: > > warning: context imbalance in 'put_rsb' - unexpected unlock > > with this patch and having the refcount_dec_and_lock() functionality > inside the if condition to decide whenever doing unlock or not the > warning disappears. > > The patch follows a similar naming scheme like raw_spin_trylock() by > adding a "raw_" prefix to refcount_dec_and_lock() functionality and > introduce a macro for the replaced functions that uses __cond_lock() > to signal that an acquire depends on the return value of the passed > function. > > A cast to bool seems to be necessary because __cond_lock() does return a > non-boolean scalar type. I hate the __cond_lock() think with a passions. Please just fix sparse to not suck.