From 7c378ed02556c0de058fe9021c0d008ff9513148 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 22 Apr 2011 03:12:18 +0000 Subject: [PATCH] Cast away alignment warnings about pointers where we never actually directly dereference pointers to the field members. Get rid of an unnecessary cast that provokes warnings. svn path=/trunk/; revision=36789 --- wiretap/pcap-common.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/wiretap/pcap-common.c b/wiretap/pcap-common.c index b699129e8e..9f8b7ce52c 100644 --- a/wiretap/pcap-common.c +++ b/wiretap/pcap-common.c @@ -1077,7 +1077,12 @@ pcap_process_linux_usb_pseudoheader(guint packet_size, gboolean byte_swapped, gint32 iso_numdesc, i; if (byte_swapped) { - phdr = (struct linux_usb_phdr *)pd; + /* + * Greasy hack, but we never directly direference any of + * the fields in *phdr, we just get offsets of and + * addresses of its members, so it's safe. + */ + phdr = (struct linux_usb_phdr *)(void *)pd; if (packet_size < END_OFFSETOF(phdr, &phdr->id)) return; @@ -1143,10 +1148,13 @@ pcap_process_linux_usb_pseudoheader(guint packet_size, gboolean byte_swapped, if (phdr->transfer_type == URB_ISOCHRONOUS) { /* swap the values in struct linux_usb_isodesc */ + /* + * See previous "Greasy hack" comment. + */ if (header_len_64_bytes) { - pisodesc = (struct linux_usb_isodesc*)(pd + 64); + pisodesc = (struct linux_usb_isodesc*)(void *)(pd + 64); } else { - pisodesc = (struct linux_usb_isodesc*)(pd + 48); + pisodesc = (struct linux_usb_isodesc*)(void *)(pd + 48); } iso_numdesc = phdr->s.iso.numdesc; for (i = 0; i < iso_numdesc; i++) { @@ -1276,7 +1284,7 @@ pcap_read_erf_exheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, return FALSE; } type = erf_exhdr[0]; - erf_exhdr_sw = pntohll((guint64*) &(erf_exhdr[0])); + erf_exhdr_sw = pntohll(erf_exhdr[0]); if (i < max) memcpy(&pseudo_header->erf.ehdr_list[i].ehdr, &erf_exhdr_sw, sizeof(erf_exhdr_sw)); *psize += 8;