Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Nov 2018 21:29:57 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r340410 - head/sys/kern
Message-ID:  <201811132129.wADLTvPC017475@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Tue Nov 13 21:29:56 2018
New Revision: 340410
URL: https://svnweb.freebsd.org/changeset/base/340410

Log:
  locks: plug warnings about unitialized variables
  
  They only showed up after I redefined LOCKSTAT_ENABLED to 0.
  
  doing_lockprof in mutex.c is a real (but harmless) bug. Should the
  value be non-zero it will do checks for lock profiling which would
  otherwise be skipped.
  
  state in rwlock.c is a wart from the compiler, the value can't be
  used if lock profiling is not enabled.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/kern/kern_mutex.c
  head/sys/kern/kern_rwlock.c

Modified: head/sys/kern/kern_mutex.c
==============================================================================
--- head/sys/kern/kern_mutex.c	Tue Nov 13 20:48:05 2018	(r340409)
+++ head/sys/kern/kern_mutex.c	Tue Nov 13 21:29:56 2018	(r340410)
@@ -486,7 +486,7 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v)
 	int64_t all_time = 0;
 #endif
 #if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
-	int doing_lockprof;
+	int doing_lockprof = 0;
 #endif
 
 	td = curthread;
@@ -690,7 +690,7 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t
 	int64_t spin_time = 0;
 #endif
 #if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
-	int doing_lockprof;
+	int doing_lockprof = 0;
 #endif
 
 	tid = (uintptr_t)curthread;

Modified: head/sys/kern/kern_rwlock.c
==============================================================================
--- head/sys/kern/kern_rwlock.c	Tue Nov 13 20:48:05 2018	(r340409)
+++ head/sys/kern/kern_rwlock.c	Tue Nov 13 21:29:56 2018	(r340410)
@@ -445,7 +445,7 @@ __rw_rlock_hard(struct rwlock *rw, struct thread *td, 
 	int64_t all_time = 0;
 #endif
 #if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
-	uintptr_t state;
+	uintptr_t state = 0;
 	int doing_lockprof = 0;
 #endif
 
@@ -913,7 +913,7 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v LOC
 	int64_t all_time = 0;
 #endif
 #if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
-	uintptr_t state;
+	uintptr_t state = 0;
 	int doing_lockprof = 0;
 #endif
 	int extra_work = 0;



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