From owner-svn-src-all@FreeBSD.ORG Sat Feb 14 17:45:36 2009 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 DB82C1065670; Sat, 14 Feb 2009 17:45:36 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.9.129]) by mx1.freebsd.org (Postfix) with ESMTP id 9BCE58FC12; Sat, 14 Feb 2009 17:45:36 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 0CBAB7309E; Sat, 14 Feb 2009 18:51:36 +0100 (CET) Date: Sat, 14 Feb 2009 18:51:36 +0100 From: Luigi Rizzo To: Bruce Evans Message-ID: <20090214175136.GB89369@onelab2.iet.unipi.it> References: <200902131514.n1DFEhft091837@svn.freebsd.org> <20090214183758.I847@besplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090214183758.I847@besplex.bde.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, Luigi Rizzo , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r188578 - 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: Sat, 14 Feb 2009 17:45:37 -0000 On Sat, Feb 14, 2009 at 06:59:57PM +1100, Bruce Evans wrote: > On Fri, 13 Feb 2009, Luigi Rizzo wrote: > > >Log: > > Use uint32_t instead of n_long and n_time, and uint16_t instead of > > n_short. > > Add a note next to fields in network format. > > > > The n_* types are not enough for compiler checks on endianness, and their > > use often requires an otherwise unnecessary #include > > This is too much like globally substituting uid_t with uint16_t. At actually uid_t are uint32_t :) But there are several differences: - uid_t, dev_t and other widelyused_t are in so you don't need to add one extra header just for the n_long typedef; - n_{long|short|time} are so rarely used that after 20 years one can safely declare they were an unsuccessful experiment; > >+#define ICMP_TSLEN (8 + 3 * sizeof (uint32_t)) /* timestamp > >*/ > > The changes lose the most where they involve sizeof's. Now it is > unclear that the sizeof is of 1 timestamp. sizeof(uint32_t) is an > obfuscated spelling of 4. True. And this is another macro used exactly one time, which probably could be retired or replaced with just the right number. > >- (void)memcpy(cp + off, &ntime, sizeof(n_time)); > >- cp[IPOPT_OFFSET] += sizeof(n_time); > >+ (void)memcpy(cp + off, &ntime, sizeof(uint32_t)); > >+ cp[IPOPT_OFFSET] += sizeof(uint32_t); > > ... but here we are copying the object `ntime'; sizeof(n_time) was an > obfuscated spelling of the size of that object, and sizeof(uint32_t) is > an even more obfuscated spelling. Similarly elsewhere. in fact, I prefer sizeof(variable) instead of sizeof(type) in these circumstances, but both forms have pros and cons and i just followed the existing form. cheers luigi