summaryrefslogtreecommitdiff
path: root/pcap-dlpi.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2010-02-23 20:01:35 -0800
committerGuy Harris <guy@alum.mit.edu>2010-02-23 20:01:35 -0800
commit84a1f947bad081f30365ee8cb308ec18d4e7d4c5 (patch)
tree95692b181f63eaa894df152da9398c8f7950dae4 /pcap-dlpi.c
parentb231bfe26cdeaa2bb9375052d5985a82eeda84ec (diff)
downloadlibpcap-84a1f947bad081f30365ee8cb308ec18d4e7d4c5.tar.gz
Squelch warnings about type punning.
Diffstat (limited to 'pcap-dlpi.c')
-rw-r--r--pcap-dlpi.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/pcap-dlpi.c b/pcap-dlpi.c
index 16fbfff5..8f938fe1 100644
--- a/pcap-dlpi.c
+++ b/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;