Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Feb 2009 18:48:11 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        "Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Ed Schouten <ed@FreeBSD.org>
Subject:   Re: svn commit: r189066 - head/sys/kern
Message-ID:  <20090227184405.Q13337@delplex.bde.org>
In-Reply-To: <20090226232352.S53478@maildrop.int.zabbadoz.net>
References:  <200902261212.n1QCCYI6027315@svn.freebsd.org> <20090226232352.S53478@maildrop.int.zabbadoz.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 26 Feb 2009, Bjoern A. Zeeb wrote:

> On Thu, 26 Feb 2009, Ed Schouten wrote:
>> Log:
>>  Remove redundant assignment of `p'.
>> 
>>  `p' is already initialized with `td->td_proc'. Because td is always
>>  curthread, it is safe to initialize it without any locks.
>> 
>>  Found by:	LLVM's scan-build
>> 
>> Modified:
>>  head/sys/kern/subr_prf.c
>> 
>> Modified: head/sys/kern/subr_prf.c
>> ==============================================================================
>> --- head/sys/kern/subr_prf.c	Thu Feb 26 12:06:46 2009	(r189065)
>> +++ head/sys/kern/subr_prf.c	Thu Feb 26 12:12:34 2009	(r189066)
>> @@ -137,7 +137,6 @@ uprintf(const char *fmt, ...)
>> 		return (0);
>> 
>> 	sx_slock(&proctree_lock);
>> -	p = td->td_proc;
>> 	PROC_LOCK(p);
>> 	if ((p->p_flag & P_CONTROLT) == 0) {
>> 		PROC_UNLOCK(p);
>
>
> I think this one is wrong. You should probably have removed the
> assignment from declaration time as we are checking for td != NULL
> just above that so it could possibly be a NULL pointer deref in the
> initial assigment or the NULL check is redundant.

Almost all of them are wrong, since they keep the assignment with the
style bug (initialization in declaration) and remove the one without
the style bug.  In libkern this also increases the divergence from the
libc versions, since the libc versions are missing the style bug.

Bruce



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