Squelch warnings about type punning.
This commit is contained in:
parent
b231bfe26c
commit
84a1f947ba
14
pcap-dlpi.c
14
pcap-dlpi.c
|
@ -180,6 +180,12 @@ static struct strbuf ctl = {
|
|||
(char *)ctlbuf
|
||||
};
|
||||
|
||||
/*
|
||||
* Cast a buffer to "union DL_primitives" without provoking warnings
|
||||
* from the compiler.
|
||||
*/
|
||||
#define MAKE_DL_PRIMITIVES(ptr) ((union DL_primitives *)(void *)(ptr))
|
||||
|
||||
static int
|
||||
pcap_read_dlpi(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
{
|
||||
|
@ -498,7 +504,7 @@ pcap_activate_dlpi(pcap_t *p)
|
|||
if (dlinforeq(p->fd, p->errbuf) < 0 ||
|
||||
dlinfoack(p->fd, (char *)buf, p->errbuf) < 0)
|
||||
goto bad;
|
||||
infop = &((union DL_primitives *)buf)->info_ack;
|
||||
infop = &(MAKE_DL_PRIMITIVES(buf))->info_ack;
|
||||
#ifdef HAVE_SOLARIS
|
||||
if (infop->dl_mac_type == DL_IPATM)
|
||||
isatm = 1;
|
||||
|
@ -674,7 +680,7 @@ pcap_activate_dlpi(pcap_t *p)
|
|||
dlinfoack(p->fd, (char *)buf, p->errbuf) < 0)
|
||||
goto bad;
|
||||
|
||||
infop = &((union DL_primitives *)buf)->info_ack;
|
||||
infop = &(MAKE_DL_PRIMITIVES(buf))->info_ack;
|
||||
if (pcap_process_mactype(p, infop->dl_mac_type) != 0)
|
||||
goto bad;
|
||||
|
||||
|
@ -959,7 +965,7 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror
|
|||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
dlp = (union DL_primitives *) ctl.buf;
|
||||
dlp = MAKE_DL_PRIMITIVES(ctl.buf);
|
||||
switch (dlp->dl_primitive) {
|
||||
|
||||
case DL_INFO_ACK:
|
||||
|
@ -1319,7 +1325,7 @@ dlrawdatareq(int fd, const u_char *datap, int datalen)
|
|||
union DL_primitives *dlp;
|
||||
int dlen;
|
||||
|
||||
dlp = (union DL_primitives*) buf;
|
||||
dlp = MAKE_DL_PRIMITIVES(buf);
|
||||
|
||||
dlp->dl_primitive = DL_HP_RAWDATA_REQ;
|
||||
dlen = DL_HP_RAWDATA_REQ_SIZE;
|
||||
|
|
Reference in New Issue