Author: markj
Date: Sat Dec 10 02:56:44 2016
New Revision: 309783
URL: https://svnweb.freebsd.org/changeset/base/309783

Log:
  Return a non-NULL owner only if the lock is exclusively held in owner_sx().
  
  Fix some whitespace bugs while here.
  
  MFC after:    2 weeks

Modified:
  head/sys/kern/kern_sx.c

Modified: head/sys/kern/kern_sx.c
==============================================================================
--- head/sys/kern/kern_sx.c     Sat Dec 10 01:40:10 2016        (r309782)
+++ head/sys/kern/kern_sx.c     Sat Dec 10 02:56:44 2016        (r309783)
@@ -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
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to