PDA

View Full Version : warning: comparison is always false due to limited range of data type



nasim751
01-31-2008, 01:21 AM
hello,
this is my define declaration
#define CLEANUP_INTERVAL 1000
and this is my function body. here getting warning like this

warning: comparison is always false due to limited range of data type

how can i over come this problem.

void
descry(u_char *u, struct pcap_pkthdr *phdr, u_char *packet)
{
struct libnet_ipv4_hdr *ip;
struct libnet_tcp_hdr *tcp;
struct descry_pack *gp;
struct tcp_connection *c;
struct tcp_connection *rc;
static u_char cleanup = 0;
struct timeval ts;

rc = NULL;
c = NULL;
gp = (struct descry_pack *)u;

/*
* In order to keep the trie from growing boundlessly, we need to
* periodically expire half open connections.
*/

if (cleanup++ > CLEANUP_INTERVAL)
{
ts.tv_usec = phdr->ts.tv_usec;
ts.tv_sec = phdr->ts.tv_sec;

/* expire old connections */
pt_expire(gp, &ts);
cleanup = 0;
}
basically using this program i want to scan TCP ip protocal.
I need your feedback.
regards
Nasim

Salem
01-31-2008, 02:02 AM
1. Just use code tags, not PHP tags.

2. static u_char cleanup = 0;
So when do you think an unsigned char will reach 1000 ?

ssharish2005
01-31-2008, 09:52 AM
why dont u use int rather than char, unsigned char can hold up to 255 that it . Look into limit.h. Use int rather than char. That should get rid of your warning.

ssharish