Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/libpcap/dist more sign-compare fixes.
details: https://anonhg.NetBSD.org/src/rev/8c997b3373eb
branches: trunk
changeset: 759275:8c997b3373eb
user: christos <christos%NetBSD.org@localhost>
date: Sun Dec 05 03:02:41 2010 +0000
description:
more sign-compare fixes.
diffstat:
external/bsd/libpcap/dist/bpf/net/bpf_filter.c | 28 +++++++++++-----------
external/bsd/libpcap/dist/sf-pcap-ng.c | 33 ++++++++++++-------------
external/bsd/libpcap/dist/sf-pcap.c | 4 +-
3 files changed, 32 insertions(+), 33 deletions(-)
diffs (246 lines):
diff -r c8ecf209771d -r 8c997b3373eb external/bsd/libpcap/dist/bpf/net/bpf_filter.c
--- a/external/bsd/libpcap/dist/bpf/net/bpf_filter.c Sun Dec 05 03:01:39 2010 +0000
+++ b/external/bsd/libpcap/dist/bpf/net/bpf_filter.c Sun Dec 05 03:02:41 2010 +0000
@@ -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:
diff -r c8ecf209771d -r 8c997b3373eb external/bsd/libpcap/dist/sf-pcap-ng.c
--- a/external/bsd/libpcap/dist/sf-pcap-ng.c Sun Dec 05 03:01:39 2010 +0000
+++ b/external/bsd/libpcap/dist/sf-pcap-ng.c Sun Dec 05 03:02:41 2010 +0000
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /cvsroot/src/external/bsd/libpcap/dist/Attic/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/Attic/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.
diff -r c8ecf209771d -r 8c997b3373eb external/bsd/libpcap/dist/sf-pcap.c
--- a/external/bsd/libpcap/dist/sf-pcap.c Sun Dec 05 03:01:39 2010 +0000
+++ b/external/bsd/libpcap/dist/sf-pcap.c Sun Dec 05 03:02:41 2010 +0000
@@ -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
Home |
Main Index |
Thread Index |
Old Index