Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Dec 2016 02:56:44 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r309783 - head/sys/kern
Message-ID:  <201612100256.uBA2uiXJ008365@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612100256.uBA2uiXJ008365>