Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Feb 2009 15:51:54 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r189074 - head/sys/kern
Message-ID:  <200902261551.n1QFpsTT031683@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Thu Feb 26 15:51:54 2009
New Revision: 189074
URL: http://svn.freebsd.org/changeset/base/189074

Log:
  Remove even more unneeded variable assignments.
  
  kern_time.c:
  - Unused variable `p'.
  
  kern_thr.c:
  - Variable `error' is always caught immediately, so no reason to
    initialize it. There is no way that error != 0 at the end of
    create_thread().
  
  kern_sig.c:
  - Unused variable `code'.
  
  kern_synch.c:
  - `rval' is always assigned in all different cases.
  
  kern_rwlock.c:
  - `v' is always overwritten with RW_UNLOCKED further on.
  
  kern_malloc.c:
  - `size' is always initialized with the proper value before being used.
  
  kern_exit.c:
  - `error' is always caught and returned immediately. abort2() never
    returns a non-zero value.
  
  kern_exec.c:
  - `len' is always assigned inside the if-statement right below it.
  
  tty_info.c:
  - `td' is always overwritten by FOREACH_THREAD_IN_PROC().
  
  Found by:	LLVM's scan-build

Modified:
  head/sys/kern/kern_exec.c
  head/sys/kern/kern_exit.c
  head/sys/kern/kern_malloc.c
  head/sys/kern/kern_rwlock.c
  head/sys/kern/kern_sig.c
  head/sys/kern/kern_synch.c
  head/sys/kern/kern_thr.c
  head/sys/kern/kern_time.c
  head/sys/kern/tty_info.c

Modified: head/sys/kern/kern_exec.c
==============================================================================
--- head/sys/kern/kern_exec.c	Thu Feb 26 14:32:14 2009	(r189073)
+++ head/sys/kern/kern_exec.c	Thu Feb 26 15:51:54 2009	(r189074)
@@ -591,7 +591,6 @@ interpret:
 		len = min(ndp->ni_cnd.cn_namelen,MAXCOMLEN);
 		bcopy(ndp->ni_cnd.cn_nameptr, p->p_comm, len);
 	} else {
-		len = MAXCOMLEN;
 		if (vn_commname(binvp, p->p_comm, MAXCOMLEN + 1) == 0)
 			len = MAXCOMLEN;
 		else {
@@ -1061,8 +1060,6 @@ exec_copyin_args(struct image_args *args
 	int error;
 	size_t length;
 
-	error = 0;
-
 	bzero(args, sizeof(*args));
 	if (argv == NULL)
 		return (EFAULT);

Modified: head/sys/kern/kern_exit.c
==============================================================================
--- head/sys/kern/kern_exit.c	Thu Feb 26 14:32:14 2009	(r189073)
+++ head/sys/kern/kern_exit.c	Thu Feb 26 15:51:54 2009	(r189074)
@@ -585,8 +585,6 @@ abort2(struct thread *td, struct abort2_
 	void *uargs[16];
 	int error, i, sig;
 
-	error = 0;	/* satisfy compiler */
-
 	/*
 	 * Do it right now so we can log either proper call of abort2(), or
 	 * note, that invalid argument was passed. 512 is big enough to

Modified: head/sys/kern/kern_malloc.c
==============================================================================
--- head/sys/kern/kern_malloc.c	Thu Feb 26 14:32:14 2009	(r189073)
+++ head/sys/kern/kern_malloc.c	Thu Feb 26 15:51:54 2009	(r189074)
@@ -435,8 +435,6 @@ free(void *addr, struct malloc_type *mtp
 	addr = redzone_addr_ntor(addr);
 #endif
 
-	size = 0;
-
 	slab = vtoslab((vm_offset_t)addr & (~UMA_SLAB_MASK));
 
 	if (slab == NULL)

Modified: head/sys/kern/kern_rwlock.c
==============================================================================
--- head/sys/kern/kern_rwlock.c	Thu Feb 26 14:32:14 2009	(r189073)
+++ head/sys/kern/kern_rwlock.c	Thu Feb 26 15:51:54 2009	(r189074)
@@ -732,7 +732,6 @@ _rw_wunlock_hard(struct rwlock *rw, uint
 			CTR2(KTR_LOCK, "%s: %p unrecursing", __func__, rw);
 		return;
 	}
-	v = rw->rw_lock;
 
 	KASSERT(rw->rw_lock & (RW_LOCK_READ_WAITERS | RW_LOCK_WRITE_WAITERS),
 	    ("%s: neither of the waiter flags are set", __func__));

Modified: head/sys/kern/kern_sig.c
==============================================================================
--- head/sys/kern/kern_sig.c	Thu Feb 26 14:32:14 2009	(r189073)
+++ head/sys/kern/kern_sig.c	Thu Feb 26 15:51:54 2009	(r189074)
@@ -2585,7 +2585,6 @@ postsig(sig)
 	sig_t action;
 	ksiginfo_t ksi;
 	sigset_t returnmask;
-	int code;
 
 	KASSERT(sig != 0, ("postsig"));
 
@@ -2653,10 +2652,7 @@ postsig(sig)
 			ps->ps_sigact[_SIG_IDX(sig)] = SIG_DFL;
 		}
 		td->td_ru.ru_nsignals++;
-		if (p->p_sig != sig) {
-			code = 0;
-		} else {
-			code = p->p_code;
+		if (p->p_sig == sig) {
 			p->p_code = 0;
 			p->p_sig = 0;
 		}

Modified: head/sys/kern/kern_synch.c
==============================================================================
--- head/sys/kern/kern_synch.c	Thu Feb 26 14:32:14 2009	(r189073)
+++ head/sys/kern/kern_synch.c	Thu Feb 26 15:51:54 2009	(r189074)
@@ -173,7 +173,6 @@ _sleep(void *ident, struct lock_object *
 	}
 	catch = priority & PCATCH;
 	pri = priority & PRIMASK;
-	rval = 0;
 
 	/*
 	 * If we are already on a sleep queue, then remove us from that

Modified: head/sys/kern/kern_thr.c
==============================================================================
--- head/sys/kern/kern_thr.c	Thu Feb 26 14:32:14 2009	(r189073)
+++ head/sys/kern/kern_thr.c	Thu Feb 26 15:51:54 2009	(r189074)
@@ -149,7 +149,6 @@ create_thread(struct thread *td, mcontex
 	struct proc *p;
 	int error;
 
-	error = 0;
 	p = td->td_proc;
 
 	/* Have race condition but it is cheap. */
@@ -253,7 +252,7 @@ create_thread(struct thread *td, mcontex
 	sched_add(newtd, SRQ_BORING);
 	thread_unlock(newtd);
 
-	return (error);
+	return (0);
 }
 
 int
@@ -403,7 +402,6 @@ thr_suspend(struct thread *td, struct th
 	struct timespec ts, *tsp;
 	int error;
 
-	error = 0;
 	tsp = NULL;
 	if (uap->timeout != NULL) {
 		error = copyin((const void *)uap->timeout, (void *)&ts,

Modified: head/sys/kern/kern_time.c
==============================================================================
--- head/sys/kern/kern_time.c	Thu Feb 26 14:32:14 2009	(r189073)
+++ head/sys/kern/kern_time.c	Thu Feb 26 15:51:54 2009	(r189074)
@@ -1367,10 +1367,8 @@ realtimer_expire(void *arg)
 	struct timespec cts, ts;
 	struct timeval tv;
 	struct itimer *it;
-	struct proc *p;
 
 	it = (struct itimer *)arg;
-	p = it->it_proc;
 
 	realtimer_clocktime(it->it_clockid, &cts);
 	/* Only fire if time is reached. */

Modified: head/sys/kern/tty_info.c
==============================================================================
--- head/sys/kern/tty_info.c	Thu Feb 26 14:32:14 2009	(r189073)
+++ head/sys/kern/tty_info.c	Thu Feb 26 15:51:54 2009	(r189074)
@@ -261,7 +261,6 @@ tty_info(struct tty *tp)
 
 	PROC_LOCK(pick);
 	picktd = NULL;
-	td = FIRST_THREAD_IN_PROC(pick);
 	FOREACH_THREAD_IN_PROC(pick, td)
 		if (thread_compare(picktd, td))
 			picktd = td;



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