]> The Tcpdump Group git mirrors - libpcap/commitdiff
Cast HANDLE to intptr_t first. 1026/head
authorBiswapriyo Nath <[email protected]>
Tue, 20 Jul 2021 10:22:12 +0000 (15:52 +0530)
committerBiswapriyo Nath <[email protected]>
Tue, 20 Jul 2021 10:22:17 +0000 (15:52 +0530)
In 64 bit system, pcap.handle is of type HANDLE aka. void* which is 8 bytes,
different that 4 bytes int. So, gcc shows warning while casting void* to int
like this warning: cast from pointer to integer of different size. This
change fixes that warning.

pcap.c

diff --git a/pcap.c b/pcap.c
index b8b8af2a73ab7798944afd9d4e5953b22f5d03d1..5ccb9aeb3b83e7a114c04f6a100d28016f936848 100644 (file)
--- a/pcap.c
+++ b/pcap.c
@@ -3462,14 +3462,14 @@ pcap_fileno(pcap_t *p)
                /*
                 * This is a bogus and now-deprecated API; we
                 * squelch the narrowing warning for the cast
-                * from HANDLE to DWORD.  If Windows programmmers
+                * from HANDLE to intptr_t.  If Windows programmmers
                 * need to get at the HANDLE for a pcap_t, *if*
                 * there is one, they should request such a
                 * routine (and be prepared for it to return
                 * INVALID_HANDLE_VALUE).
                 */
 DIAG_OFF_NARROWING
-               return ((int)(DWORD)p->handle);
+               return ((int)(intptr_t)p->handle);
 DIAG_ON_NARROWING
        } else
                return (PCAP_ERROR);