Assuming 'char' is an signed value...

Petter Reinholdtsen pere at HUNGRY.COM
Wed Jan 26 12:14:08 EST 2005


This is another interesting warning on Irix:

cc-1183 cc: WARNING File = maptemplate.c, Line = 2789
  An unsigned integer is being compared to zero.

        if(lp->resultcache->results[0].classindex >= 0 && lp->class[(int)(lp->resultcache->results[0].classindex)].template)
                                                  ^

cc-1183 cc: WARNING File = maptemplate.c, Line = 2912
  An unsigned integer is being compared to zero.

        if(lp->resultcache->results[j].classindex >= 0 && lp->class[(int)(lp->resultcache->results[j].classindex)].template)
                                                  ^

The 'classindex' struct member is a char (in resultCacheMemberObj),
and the code in question will not work as expected when char is an
unsigned type (which is the case on some archs).

What is the correct fix?  Changing the use of 'char classindex' to
'unsigned char classindex' or 'uint8_t' (from <stdint.h>), or perhaps
stop comparing the value with 0?  I recommend using uint8_t if the
intention of the code is to use an unsigned 8 bit value.



More information about the mapserver-dev mailing list