From: Keir Fraser Subject: Re: [PATCH] libfsimage: Make it build on NetBSD Date: Sun, 23 Sep 2007 12:48:11 +0100 Message-ID: References: <20070923111256.GA10709@wavehammer.waldi.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20070923111256.GA10709@wavehammer.waldi.eu.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Bastian Blank , Christoph Egger Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On 23/9/07 12:12, "Bastian Blank" wrote: > On Fri, Sep 21, 2007 at 02:39:46PM +0200, Christoph Egger wrote: >> - if (!*dirname || isspace (*dirname)) >> + if (!*dirname || isspace ((uint8_t)*dirname)) > > According to C99, the definition is "int isspace(int c)". Even char can > be converted implicitely to int. Which problem do you intend to fix with > that? If this functions are incorrectly defined on BSD, fix that their. The ISO spec is pretty unambiguous: "The c argument is an int, the value of which the application shall ensure is a character representable as an unsigned char or equal to the value of the macro EOF. If the argument has any other value, the behavior is undefined." If we sensibly take 'representable' to mean 'representable with the same integer value', then the casts are clearly needed for compliance. This interpretation even makes some sense, since it explicitly disallows collision between character code 0xff and EOF (usually -1). And read glibc's ctype.h -- it goes to some effort to support 'signed char' input, but makes it clear this is "for broken old programs". This seems to be one of the ugly corners of the C spec where the truth is not very palatable. :-) -- Keir