Group the loop to acquire/release Giant with the WITNESS_SAVE/RESTORE under

a single conditional.  The two operations are linked, but since the link
is not very direct, Coverity can't see it.  Humans might also miss the
link as well.  So, this isn't fixing any actual bugs, just improving
readability.

CID:		1787 (likely others as well)
Found by:	Coverity Prevent (tm)
This commit is contained in:
John Baldwin 2007-04-11 13:44:55 +00:00
parent 2b1d8ce08a
commit 4796ce4956

View File

@ -360,13 +360,14 @@ extern struct mtx Giant;
#ifndef DROP_GIANT
#define DROP_GIANT() \
do { \
int _giantcnt; \
int _giantcnt = 0; \
WITNESS_SAVE_DECL(Giant); \
\
if (mtx_owned(&Giant)) \
if (mtx_owned(&Giant)) { \
WITNESS_SAVE(&Giant.lock_object, Giant); \
for (_giantcnt = 0; mtx_owned(&Giant); _giantcnt++) \
mtx_unlock(&Giant)
for (_giantcnt = 0; mtx_owned(&Giant); _giantcnt++) \
mtx_unlock(&Giant); \
}
#define PICKUP_GIANT() \
PARTIAL_PICKUP_GIANT(); \
@ -374,10 +375,11 @@ do { \
#define PARTIAL_PICKUP_GIANT() \
mtx_assert(&Giant, MA_NOTOWNED); \
while (_giantcnt--) \
mtx_lock(&Giant); \
if (mtx_owned(&Giant)) \
WITNESS_RESTORE(&Giant.lock_object, Giant)
if (_giantcnt > 0) { \
while (_giantcnt--) \
mtx_lock(&Giant); \
WITNESS_RESTORE(&Giant.lock_object, Giant); \
}
#endif
#define UGAR(rval) do { \