Subject: Re: please (test and) review wip/pkg_select
To: iMil <>
From: David Laight <>
List: tech-pkg
Date: 02/21/2005 20:24:45
On Mon, Feb 21, 2005 at 01:15:00PM +0100, iMil wrote:
> Hash: SHA1
> >===> Building for pkg_select-20050221
> >#   compile  pkg_select-20050221/parsedirs.o
> >cc -O2 -g -DPKGSRCBASE=\"/usr/pkgsrc\" -DPKGDB=\"/var/db/pkg\"  -Wall 
> >-Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-sign-compare 
> >-Wno-traditional -Wno-uninitialized -Wreturn-type -Wswitch -Wshadow 
> >-Wcast-qual -Wwrite-strings  -Werror       -c    parsedirs.c
> >parsedirs.c: In function `pkgfind':
> >parsedirs.c:234: warning: subscript has type `char'
> >*** Error code 1
> strange, i can't reproduce this error here, anyway i added an int cast 
> that should correct this problem.

Nope, if this is a ctype(3) function then the int cast is almost certainly
wrong - which is why the cast was removed.  The domain of the isxxx()
functions is EOF and all the values of unsigned char - typcally [-1..255].

If you call isxxx() with a signed char then the result is undefined.  In
particular the function is often defines as (__ctype[1 + arg] & BIT_PATTERN)
so a negative value in a signed char will index off the front of the array
as look in an incorrect place for the bit-pattern.  It might even core dump.

I actually suspect that the "subscript has type `char'" warning was
implemented to specifically catch this issue.


David Laight: