From 909431013ea2e395d836f15f3508b55a98af7f15 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 19 Mar 2019 13:14:33 -0700 Subject: Squelch some compiler warnings. The size of the USB metadata header will be small enough to fit into an int; make the header_size argument to usb_set_ring_size() an int, and add casts just in case some compilers don't realize that 48 and 64 fit comfortably into an int. --- pcap-usb-linux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pcap-usb-linux.c') diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c index f202cb62..fbf6206a 100644 --- a/pcap-usb-linux.c +++ b/pcap-usb-linux.c @@ -388,7 +388,7 @@ usb_findalldevs(pcap_if_list_t *devlistp, char *err_str) #define MAX_RING_SIZE (1200*1024) static int -usb_set_ring_size(pcap_t* handle, size_t header_size) +usb_set_ring_size(pcap_t* handle, int header_size) { /* * A packet from binary usbmon has: @@ -412,7 +412,7 @@ usb_set_ring_size(pcap_t* handle, size_t header_size) */ int ring_size; - if ((size_t)handle->snapshot < header_size) + if (handle->snapshot < header_size) handle->snapshot = header_size; /* The maximum snapshot size is small enough that this won't overflow */ ring_size = (handle->snapshot - header_size) * 5; @@ -460,7 +460,7 @@ int usb_mmap(pcap_t* handle) * length, reducing the snapshot length if that'd make the ring * bigger than the kernel supports. */ - len = usb_set_ring_size(handle, sizeof(pcap_usb_header_mmapped)); + len = usb_set_ring_size(handle, (int)sizeof(pcap_usb_header_mmapped)); if (len == -1) { /* Failed. Fall back on non-memory-mapped access. */ return 0; @@ -715,7 +715,7 @@ usb_activate(pcap_t* handle) * if that'd make the ring bigger than the kernel * supports. */ - if (usb_set_ring_size(handle, sizeof(pcap_usb_header)) == -1) { + if (usb_set_ring_size(handle, (int)sizeof(pcap_usb_header)) == -1) { /* Failed. */ close(handle->fd); return PCAP_ERROR; -- cgit v1.2.3