Module Name: src Committed By: christos Date: Sun Dec 5 03:02:42 UTC 2010
Modified Files: src/external/bsd/libpcap/dist: sf-pcap-ng.c sf-pcap.c src/external/bsd/libpcap/dist/bpf/net: bpf_filter.c Log Message: more sign-compare fixes. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/libpcap/dist/sf-pcap-ng.c \ src/external/bsd/libpcap/dist/sf-pcap.c cvs rdiff -u -r1.1.1.2 -r1.2 \ src/external/bsd/libpcap/dist/bpf/net/bpf_filter.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/bsd/libpcap/dist/sf-pcap-ng.c diff -u src/external/bsd/libpcap/dist/sf-pcap-ng.c:1.1.1.1 src/external/bsd/libpcap/dist/sf-pcap-ng.c:1.2 --- src/external/bsd/libpcap/dist/sf-pcap-ng.c:1.1.1.1 Sat Dec 4 20:20:42 2010 +++ src/external/bsd/libpcap/dist/sf-pcap-ng.c Sat Dec 4 22:02:41 2010 @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /cvsroot/src/external/bsd/libpcap/dist/sf-pcap-ng.c,v 1.1.1.1 2010/12/05 01:20:42 christos Exp $ (LBL)"; + "@(#) $Header: /cvsroot/src/external/bsd/libpcap/dist/sf-pcap-ng.c,v 1.2 2010/12/05 03:02:41 christos Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -274,7 +274,7 @@ /* * Is the buffer big enough? */ - if (p->bufsize < bhdr.total_length) { + if (p->bufsize < (int)bhdr.total_length) { /* * No - make it big enough. */ @@ -348,7 +348,7 @@ */ if (p->sf.swapped) { opthdr->option_code = SWAPSHORT(opthdr->option_code); - opthdr->option_length = SWAPSHORT(opthdr->option_length); + opthdr->option_length = SWAPSHORT((uint32_t)opthdr->option_length); } return (opthdr); @@ -482,7 +482,7 @@ saw_tsoffset = 1; memcpy(tsoffset, optvalue, sizeof(*tsoffset)); if (p->sf.swapped) - *tsoffset = SWAPLL(*tsoffset); + *tsoffset = (uint64_t)SWAPLL(*tsoffset); break; default: @@ -604,7 +604,7 @@ * If we find a bigger block, we reallocate the buffer. */ p->bufsize = 2048; - if (p->bufsize < total_length) + if (p->bufsize < (int)total_length) p->bufsize = total_length; p->buffer = malloc(p->bufsize); if (p->buffer == NULL) { @@ -616,8 +616,8 @@ * Copy the stuff we've read to the buffer, and read the rest * of the SHB. */ - bhdrp = (struct block_header *)p->buffer; - shbp = (struct section_header_block *)(p->buffer + sizeof(struct block_header)); + bhdrp = (struct block_header *)(void *)p->buffer; + shbp = (struct section_header_block *)(void *)(p->buffer + sizeof(struct block_header)); bhdrp->block_type = magic; bhdrp->total_length = total_length; shbp->byte_order_magic = byte_order_magic; @@ -631,8 +631,8 @@ /* * Byte-swap the fields we've read. */ - shbp->major_version = SWAPSHORT(shbp->major_version); - shbp->minor_version = SWAPSHORT(shbp->minor_version); + shbp->major_version = SWAPSHORT((uint32_t)shbp->major_version); + shbp->minor_version = SWAPSHORT((uint32_t)shbp->minor_version); /* * XXX - we don't care about the section length. @@ -686,7 +686,7 @@ * Byte-swap it if necessary. */ if (p->sf.swapped) { - idbp->linktype = SWAPSHORT(idbp->linktype); + idbp->linktype = SWAPSHORT((uint16_t)idbp->linktype); idbp->snaplen = SWAPLONG(idbp->snaplen); } @@ -823,7 +823,6 @@ t = ((u_int64_t)epbp->timestamp_high) << 32 | epbp->timestamp_low; } - pblock_len = sizeof(*epbp); goto found; case BT_SPB: @@ -857,7 +856,7 @@ * and the packet length. */ hdr->caplen = hdr->len; - if (hdr->caplen > p->snapshot) + if ((int)hdr->caplen > p->snapshot) hdr->caplen = p->snapshot; t = 0; /* no time stamps */ pblock_len = sizeof(*spbp); @@ -878,7 +877,7 @@ */ if (p->sf.swapped) { /* these were written in opposite byte order */ - interface_id = SWAPSHORT(pbp->interface_id); + interface_id = SWAPSHORT((uint32_t)pbp->interface_id); hdr->caplen = SWAPLONG(pbp->caplen); hdr->len = SWAPLONG(pbp->len); t = ((u_int64_t)SWAPLONG(pbp->timestamp_high)) << 32 | @@ -907,7 +906,7 @@ * Byte-swap it if necessary. */ if (p->sf.swapped) { - idbp->linktype = SWAPSHORT(idbp->linktype); + idbp->linktype = SWAPSHORT((uint32_t)idbp->linktype); idbp->snaplen = SWAPLONG(idbp->snaplen); } @@ -925,7 +924,7 @@ idbp->linktype); return (-1); } - if (p->snapshot != idbp->snaplen) { + if (p->snapshot != (int)idbp->snaplen) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "an interface has a snapshot length %u different from the type of the first interface", idbp->snaplen); @@ -985,7 +984,7 @@ shbp->byte_order_magic = SWAPLONG(shbp->byte_order_magic); shbp->major_version = - SWAPSHORT(shbp->major_version); + SWAPSHORT((uint32_t)shbp->major_version); } /* @@ -1082,7 +1081,7 @@ frac *= p->sf.tsscale; } hdr->ts.tv_sec = sec; - hdr->ts.tv_usec = frac; + hdr->ts.tv_usec = (suseconds_t)frac; /* * Get a pointer to the packet data. Index: src/external/bsd/libpcap/dist/sf-pcap.c diff -u src/external/bsd/libpcap/dist/sf-pcap.c:1.1.1.1 src/external/bsd/libpcap/dist/sf-pcap.c:1.2 --- src/external/bsd/libpcap/dist/sf-pcap.c:1.1.1.1 Sat Dec 4 20:20:44 2010 +++ src/external/bsd/libpcap/dist/sf-pcap.c Sat Dec 4 22:02:41 2010 @@ -30,7 +30,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /cvsroot/src/external/bsd/libpcap/dist/sf-pcap.c,v 1.1.1.1 2010/12/05 01:20:44 christos Exp $ (LBL)"; + "@(#) $Header: /cvsroot/src/external/bsd/libpcap/dist/sf-pcap.c,v 1.2 2010/12/05 03:02:41 christos Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -357,7 +357,7 @@ break; } - if (hdr->caplen > p->bufsize) { + if ((int)hdr->caplen > p->bufsize) { /* * This can happen due to Solaris 2.3 systems tripping * over the BUFMOD problem and not setting the snapshot Index: src/external/bsd/libpcap/dist/bpf/net/bpf_filter.c diff -u src/external/bsd/libpcap/dist/bpf/net/bpf_filter.c:1.1.1.2 src/external/bsd/libpcap/dist/bpf/net/bpf_filter.c:1.2 --- src/external/bsd/libpcap/dist/bpf/net/bpf_filter.c:1.1.1.2 Sat Dec 4 20:27:26 2010 +++ src/external/bsd/libpcap/dist/bpf/net/bpf_filter.c Sat Dec 4 22:02:41 2010 @@ -108,18 +108,18 @@ #include <netinet/in.h> #endif -#define EXTRACT_SHORT(p) ((u_short)ntohs(*(u_short *)p)) -#define EXTRACT_LONG(p) (ntohl(*(u_int32 *)p)) +#define EXTRACT_SHORT(p) ((u_short)ntohs(*(const u_short *)p)) +#define EXTRACT_LONG(p) (ntohl(*(const u_int32 *)p)) #else #define EXTRACT_SHORT(p)\ ((u_short)\ - ((u_short)*((u_char *)p+0)<<8|\ - (u_short)*((u_char *)p+1)<<0)) + ((u_short)*((const u_char *)p+0)<<8|\ + (u_short)*((const u_char *)p+1)<<0)) #define EXTRACT_LONG(p)\ - ((u_int32)*((u_char *)p+0)<<24|\ - (u_int32)*((u_char *)p+1)<<16|\ - (u_int32)*((u_char *)p+2)<<8|\ - (u_int32)*((u_char *)p+3)<<0) + ((u_int32)*((const u_char *)p+0)<<24|\ + (u_int32)*((const u_char *)p+1)<<16|\ + (u_int32)*((const u_char *)p+2)<<8|\ + (u_int32)*((const u_char *)p+3)<<0) #endif #if defined(KERNEL) || defined(_KERNEL) @@ -289,7 +289,7 @@ case BPF_LD|BPF_B|BPF_ABS: k = pc->k; - if (k >= buflen) { + if (k >= (int)buflen) { #if defined(KERNEL) || defined(_KERNEL) if (m == NULL) return 0; @@ -348,7 +348,7 @@ case BPF_LD|BPF_B|BPF_IND: k = X + pc->k; - if (k >= buflen) { + if (k >= (int)buflen) { #if defined(KERNEL) || defined(_KERNEL) if (m == NULL) return 0; @@ -365,7 +365,7 @@ case BPF_LDX|BPF_MSH|BPF_B: k = pc->k; - if (k >= buflen) { + if (k >= (int)buflen) { #if defined(KERNEL) || defined(_KERNEL) if (m == NULL) return 0; @@ -550,7 +550,7 @@ return 0; #endif - for (i = 0; i < len; ++i) { + for (i = 0; i < (u_int)len; ++i) { p = &f[i]; switch (BPF_CLASS(p->code)) { /* @@ -648,7 +648,7 @@ #if defined(KERNEL) || defined(_KERNEL) if (from + p->k < from || from + p->k >= len) #else - if (from + p->k >= len) + if (from + p->k >= (u_int)len) #endif return 0; break; @@ -656,7 +656,7 @@ case BPF_JGT: case BPF_JGE: case BPF_JSET: - if (from + p->jt >= len || from + p->jf >= len) + if (from + p->jt >= (u_int)len || from + p->jf >= (u_int)len) return 0; break; default: