pkgsrc-WIP-review archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: please (test and) review wip/pkg_select



On Mon, Feb 21, 2005 at 01:15:00PM +0100, iMil wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> 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

-- 
David Laight: david%l8s.co.uk@localhost


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
pkgsrc-wip-review mailing list
pkgsrc-wip-review%lists.sourceforge.net@localhost
https://lists.sourceforge.net/lists/listinfo/pkgsrc-wip-review



Home | Main Index | Thread Index | Old Index