]> xenbits.xensource.com Git - people/royger/freebsd.git/commitdiff
Return a non-NULL owner only if the lock is exclusively held in owner_sx().
authormarkj <markj@FreeBSD.org>
Sat, 10 Dec 2016 02:56:44 +0000 (02:56 +0000)
committermarkj <markj@FreeBSD.org>
Sat, 10 Dec 2016 02:56:44 +0000 (02:56 +0000)
Fix some whitespace bugs while here.

MFC after: 2 weeks

sys/kern/kern_sx.c

index 9115d5a82ed1aab63e5b21b3948111fd9dc0f1b5..0036734caff13669769cc209c0b26e78836cfce2 100644 (file)
@@ -215,12 +215,14 @@ unlock_sx(struct lock_object *lock)
 int
 owner_sx(const struct lock_object *lock, struct thread **owner)
 {
-        const struct sx *sx = (const struct sx *)lock;
-       uintptr_t x = sx->sx_lock;
+       const struct sx *sx;
+       uintptr_t x;
 
-        *owner = (struct thread *)SX_OWNER(x);
-        return ((x & SX_LOCK_SHARED) != 0 ? (SX_SHARERS(x) != 0) :
-           (*owner != NULL));
+       sx = (const struct sx *)lock;
+       x = sx->sx_lock;
+       *owner = NULL;
+       return ((x & SX_LOCK_SHARED) != 0 ? (SX_SHARERS(x) != 0) :
+           ((*owner = (struct thread *)SX_OWNER(x)) != NULL));
 }
 #endif