pcap_rw: Fix compiler warnings
authorTobias Klauser <tklauser@distanz.ch>
Fri, 9 Aug 2013 10:22:32 +0000 (9 12:22 +0200)
committerTobias Klauser <tklauser@distanz.ch>
Fri, 9 Aug 2013 10:22:32 +0000 (9 12:22 +0200)
Fix the following compiler warnings that occur when building with "-W
-Wall -Wextra":

pcap_rw.c: In function ‘pcap_rw_write’:
pcap_rw.c:30:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
pcap_rw.c: In function ‘pcap_rw_read’:
pcap_rw.c:50:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

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

index 65b45cb..5a739da 100644 (file)
--- a/pcap_rw.c
+++ b/pcap_rw.c
@@ -27,7 +27,7 @@ static ssize_t pcap_rw_write(int fd, pcap_pkthdr_t *phdr, enum pcap_type type,
                panic("Failed to write pkt header!\n");
 
        hdrlen = pcap_get_length(phdr, type);
-       if (unlikely(hdrlen != len))
+       if (unlikely(hdrlen != (ssize_t) len))
                return -EINVAL;
 
        ret = write_or_die(fd, packet, hdrlen);
@@ -47,7 +47,7 @@ static ssize_t pcap_rw_read(int fd, pcap_pkthdr_t *phdr, enum pcap_type type,
                return -EIO;
 
        hdrlen = pcap_get_length(phdr, type);
-       if (unlikely(hdrlen == 0 || hdrlen > len))
+       if (unlikely(hdrlen == 0 || hdrlen > (ssize_t) len))
                 return -EINVAL;
 
        ret = read(fd, packet, hdrlen);