From owner-freebsd-current@FreeBSD.ORG Wed Jun 20 12:34:50 2007 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5F0D416A468 for ; Wed, 20 Jun 2007 12:34:50 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 1F4D113C458 for ; Wed, 20 Jun 2007 12:34:50 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.14.1/8.14.1/NETPLEX) with ESMTP id l5KCYk7w010785; Wed, 20 Jun 2007 08:34:47 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-3.0 (mail.ntplx.net [204.213.176.10]); Wed, 20 Jun 2007 08:34:47 -0400 (EDT) Date: Wed, 20 Jun 2007 08:34:46 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Stefan Farfeleder In-Reply-To: <20070620110702.GB929@lizard.fafoe.narf.at> Message-ID: References: <46765CB9.9020105@incunabulum.net> <4676C30E.7040300@incunabulum.net> <4676C952.5000607@incunabulum.net> <4676D168.3050502@incunabulum.net> <4678529A.3080308@incunabulum.net> <20070620110702.GB929@lizard.fafoe.narf.at> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: current@freebsd.org Subject: socklen_t (Re: Multicast problems [PATCH]) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2007 12:34:50 -0000 On Wed, 20 Jun 2007, Stefan Farfeleder wrote: > On Tue, Jun 19, 2007 at 06:36:39PM -0400, Daniel Eischen wrote: > >> POSIX states that: >> >> o The header shall define the type socklen_t, >> which is an integer type of width of at least 32 bits; see >> APPLICATION USAGE. >> >> and goes on to state: >> >> o The header shall define the unsigned integer >> type sa_family_t. >> >> This seems to imply that our socklen_t should not be an unsigned >> integer (uint32_t), but a signed integer. In APPLICATION USAGE, >> POSIX states: > > I don't understand how you come to that conclusion. Why does not > mentioning whether socklen_t is signed or unsigned imply it should be > signed? Because it explicitly says unsigned for sa_family_t and does not say unsigned for socklen_t. To me, "integer" means a C (signed) integer. The fact that older APIs and implementations used "int" might support the argument to use int32_t just for compatibility reasons. As it stands now, portable code has to have some sort of autoconfig to determine whether or not to use socklen_t or int. I don't see how you can do this with #ifdefs unless you know OS version numbers and when socklen_t first got introduced. >> To forestall portability problems, it is recommended that >> applications not use values larger than 23^1 -1 for the >> socklen_t type. > > That just means that those values will wrap to negative values if > socklen_t is a signed integer type. -- DE