staging: lustre/lustre/obdclass/llog_cat.c: get rid of sparse context imbalance warning
PATCH 1/1 staging: lustre/lustre/obdclass/llog_cat.c: get rid of sparse context imbalance warning
In llog_cat_new_log(), sparse emits a context imbalance (unexpected lock) warning due its inability to detect the noreturn attribute in lbug_with_lock() function inside LBUG macro. With this patch, we unlock the spinlock before checking the error condition to resolve this warning.
--- drivers/staging/lustre/lustre/obdclass/llog_cat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/obdclass/llog_cat.c +3 -3
@@ -103,13 +103,13 @@ static int llog_cat_new_log(const struct lu_env *env,spin_lock (&loghandle->lgh_hdr_lock); llh->llh_count++; -if (ext2_set_bit (index, llh->llh_bitmap)) { + rc =ext2_set_bit (index, llh->llh_bitmap); +spin_unlock (&loghandle->lgh_hdr_lock); +if (rc) {CERROR ("argh, index %u already set in log bitmap?\n" , index); -spin_unlock (&loghandle->lgh_hdr_lock);LBUG ();/* should never happen */ } -spin_unlock (&loghandle->lgh_hdr_lock); cathandle->lgh_last_idx = index; llh->llh_tail.lrt_index = index;
Signature · 1 line
2.4.2
Greg Kroah-Hartman
maintainerQuoted 4 lines · Tolga Ceylan
In
llog_cat_new_log(), sparse emits a context imbalance (unexpected lock) warning due its inability to detect the noreturn attribute inlbug_with_lock()function inside LBUG macro. With this patch, we unlock the spinlock before checking the error condition to resolve this warning.
That's a bug in sparse, not in the code, please don't work around tool bugs by changing kernel code.
thanks,
greg k-h