char apparantly considered unsigned ...

Peter Van Epp vanepp at sfu.ca
Mon Jan 21 14:29:22 EST 2008


	It looks like gcc on PPC Power5/SUSE thinks a char is unsigned. Thus
is always true (since it can't go negative). I expect a cast would fix it 
but perhaps there is a better way (declaring srcint signed char)?

vi argus/ArgusModeler.h


struct ArgusFlowStruct {
   struct ArgusQueueHeader qhdr;
   struct ArgusHashTableHeader htblbuf, *htblhdr;
   struct ArgusDSRHeader *dsrs[ARGUSMAXFLOWTYPE];
   struct ArgusQueueStruct frag;

   unsigned int status, dsrindex;
   unsigned int ArgusEncaps;

   unsigned short trans, timeout;
   unsigned short userlen;
   char srcint, dstint;


gcc -g  -Wall -Wmissing-prototypes -Wstrict-prototypes -m64 -fPIC -I.  -I./../include  -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_SYSLOG_H=1 -DHAVE_SYS_VFS_H=1 -DHAVE_VFPRINTF=1 -DHAVE_STRCASECMP=1 -DHAVE_STRDUP=1 -DHAVE_STRFTIME=1 -DHAVE_SETLINEBUF=1 -DHAVE_ALARM=1 -DHAVE_STRERROR=1 -DHAVE_STRTOF=1 -DHAVE_SYS_BITYPES_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_VSNPRINTF=1 -DHAVE_SNPRINTF=1 -DHAVE_GETADDRINFO=1 -DHAVE_ETHER_HOSTTON=1 -DHAVE_NETINET_ETHER_H=1 -DNETINET_ETHER_H_DECLARES_ETHER_HOSTTON= -DHAVE_DECL_ETHER_HOSTTON=1 -D_FILE_OFFSET_BITS=64 -DHAVE_PCAP_LIST_DATALINKS=1 -DHAVE_PCAP_SET_DATALINK=1 -DHAVE_PCAP_DATALINK_NAME_TO_VAL=1 -DHAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION=1 -DHAVE_PCAP_BREAKLOOP=1 -DHAVE_PCAP_DUMP_FTELL=1 -DHAVE_TCP_WRAPPER=1 -DARGUSDEBUG=1 -DSTDC_HEADERS=1  -DARGUS_SYSLOG=1 -c ArgusModeler.c
ArgusModeler.c: In function bArgusUpdateBasicFlowb:
ArgusModeler.c:1742: warning: comparison is always true due to limited range of data type
ArgusModeler.c:1749: warning: comparison is always true due to limited range of data type

vi argus/ArgusModeler.c

   if (model->ArgusThisDir) {
      if (flow->srcint >= 0) {
         if (flow->srcint != model->ArgusThisInterface) {
            flow->canon.encaps.hdr.argus_dsrvl8.qual |= ARGUS_SRC_INT_CHANGED;
         }
      } else
         flow->srcint = model->ArgusThisInterface;

	presumably model->ArgusThisInterface (or something else that will set
flow->srcint) can be negative but since it is a char, it is being considered
unsigned.

Peter Van Epp / Operations and Technical Support 
Simon Fraser University, Burnaby, B.C. Canada



More information about the argus mailing list