]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Fix a warning
authorFrancois-Xavier Le Bail <[email protected]>
Sun, 21 Jul 2019 13:20:54 +0000 (15:20 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Sun, 21 Jul 2019 13:20:54 +0000 (15:20 +0200)
The warning was:
./tcpdump.c:1059:7: warning: implicit conversion loses integer precision:
  'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
        cc = read(fd, cp, (u_int)buf.st_size);
           ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tcpdump.c

index 52af74af5fbdcb581c0d555cd53e93a99383e55d..53164a7f20f601e4c3c1027c3bb65f22194e3ef7 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1041,7 +1041,8 @@ copy_argv(char **argv)
 static char *
 read_infile(char *fname)
 {
-       int i, fd, cc;
+       int i, fd;
+       ssize_t cc;
        char *cp;
        struct stat buf;
 
@@ -1060,7 +1061,7 @@ read_infile(char *fname)
        if (cc < 0)
                error("read %s: %s", fname, pcap_strerror(errno));
        if (cc != buf.st_size)
-               error("short read %s (%d != %d)", fname, cc, (int)buf.st_size);
+               error("short read %s (%zd != %d)", fname, cc, (int)buf.st_size);
 
        close(fd);
        /* replace "# comment" with spaces */