diff --git a/monitor/control.c b/monitor/control.c
index 3447b7a..9b76038 100644
--- a/monitor/control.c
+++ b/monitor/control.c
while (1) {
struct cmsghdr *cmsg;
struct timeval *tv = NULL;
+ struct timeval ctv;
uint16_t opcode, index, pktlen;
ssize_t len;
if (cmsg->cmsg_level != SOL_SOCKET)
continue;
- if (cmsg->cmsg_type == SCM_TIMESTAMP)
- tv = (struct timeval *) CMSG_DATA(cmsg);
+ if (cmsg->cmsg_type == SCM_TIMESTAMP) {
+ memcpy(&ctv, CMSG_DATA(cmsg), sizeof(ctv));
+ tv = &ctv;
+ }
}
opcode = btohs(hdr.opcode);
diff --git a/monitor/hcidump.c b/monitor/hcidump.c
index e69bcb1..9881bb3 100644
--- a/monitor/hcidump.c
+++ b/monitor/hcidump.c
while (1) {
struct cmsghdr *cmsg;
struct timeval *tv = NULL;
- int *dir = NULL;
+ struct timeval ctv;
+ int dir = -1;
ssize_t len;
len = recvmsg(fd, &msg, MSG_DONTWAIT);
switch (cmsg->cmsg_type) {
case HCI_DATA_DIR:
- dir = (int *) CMSG_DATA(cmsg);
+ memcpy(&dir, CMSG_DATA(cmsg), sizeof(dir));
break;
case HCI_CMSG_TSTAMP:
- tv = (struct timeval *) CMSG_DATA(cmsg);
+ memcpy(&ctv, CMSG_DATA(cmsg), sizeof(ctv));
+ tv = &ctv;
break;
}
}
- if (!dir || len < 1)
+ if (dir < 0 || len < 1)
continue;
switch (buf[0]) {
packet_hci_event(tv, data->index, buf + 1, len - 1);
break;
case HCI_ACLDATA_PKT:
- packet_hci_acldata(tv, data->index, !!(*dir),
+ packet_hci_acldata(tv, data->index, !!dir,
buf + 1, len - 1);
break;
case HCI_SCODATA_PKT:
- packet_hci_scodata(tv, data->index, !!(*dir),
+ packet_hci_scodata(tv, data->index, !!dir,
buf + 1, len - 1);
break;
}
evt_stack_internal *si;
evt_si_device *sd;
struct timeval *tv = NULL;
+ struct timeval ctv;
uint8_t type = 0xff, bus = 0xff;
char str[18], name[8] = "";
bdaddr_t bdaddr;
switch (cmsg->cmsg_type) {
case HCI_CMSG_TSTAMP:
- tv = (struct timeval *) CMSG_DATA(cmsg);
+ memcpy(&ctv, CMSG_DATA(cmsg), sizeof(ctv));
+ tv = &ctv;
break;
}
}