Re: Some architectures need "signed char" declarations - Mailing list pgsql-hackers

From Doug McNaught
Subject Re: Some architectures need "signed char" declarations
Date
Msg-id m3pu4jabfb.fsf@varsoon.denali.to
Whole thread Raw
In response to Some architectures need "signed char" declarations  (Oliver Elphick <olly@lfix.co.uk>)
Responses Re: Some architectures need "signed char" declarations  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Oliver Elphick <olly@lfix.co.uk> writes:

> I recently got a Debian bug report about 3 architectures where char is
> unsigned by default.  There were 2 locations identified in the code
> where a char is compared with a negative value, and should therefore be
> declared as a "signed char".  There may be others in 7.2, but I don't
> myself have access to a suitable machine for testing.
> 
> The locations I am aware of are:
> 
>     src/backend/libpq/hba.c    GetCharSetByHost(): if (c == EOF)
>     src/backend/utils/init/miscinit.c  SetCharSet(): if (c == EOF)
> 
> The architectures are Linux on: arm, powerpc and s390.

Hmmm, according to my knowledge of C, 'c' should be an int here, as
EOF is guaranteed not to collide with any legal char value.  With 'c'
an unsigned char, ASCII 255 and EOF would be indistingushable on
twos-complement machines. 

-Doug
-- 
Let us cross over the river, and rest under the shade of the trees.  --T. J. Jackson, 1863


pgsql-hackers by date:

Previous
From: mlw
Date:
Subject: Re: RC1 time? (Server time)
Next
From: Oleg Bartunov
Date:
Subject: Re: RC1 time? (Server time)