summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authortsutsui <tsutsui@NetBSD.org>2010-08-14 09:02:17 +0000
committertsutsui <tsutsui@NetBSD.org>2010-08-14 09:02:17 +0000
commit6cc75bd4ed841257c0fe32922bca14913a7ffc77 (patch)
treec35d776a7c30bc632890e11d71b93d0517dd26c5 /sys/dev/usb
parent12c4b3b7951e00ff26d67b845ba1768f5af2177b (diff)
Make pointer arithmetics of RX buf in axe_rxeof() more readable
to avoid further confusion.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/if_axe.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c
index 6d596694dcb..810371bcb72 100644
--- a/sys/dev/usb/if_axe.c
+++ b/sys/dev/usb/if_axe.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axe.c,v 1.41 2010/08/14 08:42:15 tsutsui Exp $ */
+/* $NetBSD: if_axe.c,v 1.42 2010/08/14 09:02:17 tsutsui Exp $ */
/* $OpenBSD: if_axe.c,v 1.96 2010/01/09 05:33:08 jsg Exp $ */
/*
@@ -89,7 +89,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.41 2010/08/14 08:42:15 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.42 2010/08/14 09:02:17 tsutsui Exp $");
#if defined(__NetBSD__)
#include "opt_inet.h"
@@ -926,7 +926,7 @@ axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
struct ifnet *ifp;
uint8_t *buf;
uint32_t total_len;
- uint16_t pktlen = 0;
+ u_int rxlen, pktlen;
struct mbuf *m;
struct axe_sframe_hdr hdr;
int s;
@@ -963,31 +963,28 @@ axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
ifp->if_ierrors++;
goto done;
}
- buf += pktlen;
memcpy(&hdr, buf, sizeof(hdr));
total_len -= sizeof(hdr);
+ buf += sizeof(hdr);
if ((hdr.len ^ hdr.ilen) != 0xffff) {
ifp->if_ierrors++;
goto done;
}
- pktlen = le16toh(hdr.len);
- if (pktlen > total_len) {
- ifp->if_ierrors++;
- goto done;
- }
-
- buf += sizeof(hdr);
-
- pktlen = roundup2(pktlen, 2);
- if (total_len < pktlen)
+ rxlen = le16toh(hdr.len);
+ if (total_len < rxlen) {
+ pktlen = total_len;
total_len = 0;
- else
- total_len -= pktlen;
+ } else {
+ total_len -= rxlen;
+ pktlen = rxlen;
+ }
+ rxlen = roundup2(rxlen, 2);
+
} else { /* AX172 */
- pktlen = total_len;
+ pktlen = rxlen = total_len;
total_len = 0;
}
@@ -1004,6 +1001,7 @@ axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
m->m_pkthdr.len = m->m_len = pktlen;
memcpy(mtod(m, char *), buf, pktlen);
+ buf += rxlen;
s = splnet();