pcap_mm: Fix compiler warnings
authorTobias Klauser <tklauser@distanz.ch>
Sun, 11 Aug 2013 12:21:46 +0000 (11 14:21 +0200)
committerTobias Klauser <tklauser@distanz.ch>
Sun, 11 Aug 2013 12:21:46 +0000 (11 14:21 +0200)
Fix the following compiler warnings that occur when building with "-W
-Wall -Wextra":

pcap_mm.c: In function ‘pcap_mm_read’:
pcap_mm.c:72:73: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
pcap_mm.c:79:72: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
pcap_mm.c

index 486fbfe..0c4114e 100644 (file)
--- a/pcap_mm.c
+++ b/pcap_mm.c
@@ -69,14 +69,14 @@ static ssize_t pcap_mm_read(int fd __maybe_unused, pcap_pkthdr_t *phdr,
 {
        size_t hdrsize = pcap_get_hdr_length(phdr, type), hdrlen;
 
-       if (unlikely((off_t) (ptr_va_curr + hdrsize - ptr_va_start) > map_size))
+       if (unlikely((off_t) (ptr_va_curr + hdrsize - ptr_va_start) > (off_t) map_size))
                return -EIO;
 
        fmemcpy(&phdr->raw, ptr_va_curr, hdrsize);
        ptr_va_curr += hdrsize;
        hdrlen = pcap_get_length(phdr, type);
 
-       if (unlikely((off_t) (ptr_va_curr + hdrlen - ptr_va_start) > map_size))
+       if (unlikely((off_t) (ptr_va_curr + hdrlen - ptr_va_start) > (off_t) map_size))
                return -EIO;
        if (unlikely(hdrlen == 0 || hdrlen > len))
                return -EINVAL;