From owner-svn-src-all@FreeBSD.ORG Thu Dec 2 03:45:48 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2581106564A; Thu, 2 Dec 2010 03:45:48 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail03.syd.optusnet.com.au (mail03.syd.optusnet.com.au [211.29.132.184]) by mx1.freebsd.org (Postfix) with ESMTP id 5D4288FC13; Thu, 2 Dec 2010 03:45:47 +0000 (UTC) Received: from c122-106-145-124.carlnfd1.nsw.optusnet.com.au (c122-106-145-124.carlnfd1.nsw.optusnet.com.au [122.106.145.124]) by mail03.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id oB23jiMr020143 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 2 Dec 2010 14:45:45 +1100 Date: Thu, 2 Dec 2010 14:45:44 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Lawrence Stewart In-Reply-To: <201012020047.oB20lte1062102@svn.freebsd.org> Message-ID: <20101202141735.B1174@besplex.bde.org> References: <201012020047.oB20lte1062102@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r216101 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Dec 2010 03:45:48 -0000 On Thu, 2 Dec 2010, Lawrence Stewart wrote: > Log: > Pass NULL instead of 0 for the th pointer value. NULL != 0 on all platforms. > > Submitted by: David Hayes > MFC after: 9 weeks > X-MFC with: r215166 > > Modified: > head/sys/netinet/tcp_timer.c > > Modified: head/sys/netinet/tcp_timer.c > ============================================================================== > --- head/sys/netinet/tcp_timer.c Wed Dec 1 23:26:32 2010 (r216100) > +++ head/sys/netinet/tcp_timer.c Thu Dec 2 00:47:55 2010 (r216101) > @@ -567,7 +567,7 @@ tcp_timer_rexmt(void * xtp) > */ > tp->t_rtttime = 0; > > - cc_cong_signal(tp, 0, CC_RTO); > + cc_cong_signal(tp, NULL, CC_RTO); > > (void) tcp_output(tp); > Er this never passed 0, (provided a prototype is in scope), and can neverpass either 0 or NULL, since 0 and NULL are null pointer constants and functions cannot pass constants. It used to pass a null pointer, after converting the null pointer constant 0 according to the prototype. Now it passes the same null pointer after converting the possibly-different null pointer constant NULL according to the prototype. NULL == 0 on all platform, since both are null pointer constants, and one of the following cases applies: - if NULL is an integer constant with value 0, then of course it equals plain int 0. Moreover, even if the type of NULL is different from the type of plain int 0, the types become identical before the comparison is done, since both operands are converted to a common type. - if NULL is an integer constant with value 0 cast to (void *), then it certainly has a different type than plain int 0, and may have a different representation. However, when compared with plain 0, both operands are converted to a common type, which is necessarily that of NULL. This is a pointer type, so so both operands are null pointers. These null pointers may have different representations, but any two null pointers to the same type are specified to compare equal. So NULL == 0 in this case too. The last case is essentially what applies in function calls. Now the conversion of either NULL or 0 or any other null pointer constant to a null pointer is done according to the prototype. The results are not necessarily the same like I said above, but they compare the same. Thus spelling the null pointer constant as 0 made no difference to the higher-level results on any platform (unless you do something like memcmp of null pointers, and use an exotic platform where null pointers have different representations). It was just a style bug. Bruce