Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Convert debug printf to KASSERTMSG for check of ...



details:   https://anonhg.NetBSD.org/src/rev/834c8bd742a7
branches:  trunk
changeset: 364986:834c8bd742a7
user:      rin <rin%NetBSD.org@localhost>
date:      Fri Aug 31 11:21:00 2018 +0000

description:
Convert debug printf to KASSERTMSG for check of RX buffer length.
Also turn KASSERT into KASSERTMSG for that of TX buffer.

diffstat:

 sys/dev/usb/if_mue.c |  13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diffs (41 lines):

diff -r 9c87418e5fbd -r 834c8bd742a7 sys/dev/usb/if_mue.c
--- a/sys/dev/usb/if_mue.c      Fri Aug 31 11:18:35 2018 +0000
+++ b/sys/dev/usb/if_mue.c      Fri Aug 31 11:21:00 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mue.c,v 1.4 2018/08/30 09:59:12 rin Exp $   */
+/*     $NetBSD: if_mue.c,v 1.5 2018/08/31 11:21:00 rin Exp $   */
 /*     $OpenBSD: if_mue.c,v 1.3 2018/08/04 16:42:46 jsg Exp $  */
 
 /*
@@ -20,7 +20,7 @@
 /* Driver for Microchip LAN7500/LAN7800 chipsets. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.4 2018/08/30 09:59:12 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.5 2018/08/31 11:21:00 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1229,7 +1229,8 @@
        memcpy(c->mue_buf, &hdr, sizeof(hdr)); 
        len = sizeof(hdr);
 
-       KASSERT(len + m->m_pkthdr.len <= sc->mue_txbufsz);
+       KASSERTMSG(len + m->m_pkthdr.len <= sc->mue_txbufsz, "%d <= %u",
+           len + m->m_pkthdr.len, sc->mue_txbufsz);
 
        m_copydata(m, 0, m->m_pkthdr.len, c->mue_buf + len);
        len += m->m_pkthdr.len;
@@ -1447,10 +1448,8 @@
 
        usbd_get_xfer_status(xfer, NULL, NULL, &total_len, NULL);
 
-       if (__predict_false(total_len > sc->mue_rxbufsz)) {
-               DPRINTF(sc, "too large transfer\n");
-               goto done;
-       }
+       KASSERTMSG(total_len <= sc->mue_rxbufsz, "%d <= %u",
+           total_len, sc->mue_rxbufsz);
 
        do {
                if (__predict_false(total_len < sizeof(*hdrp))) {



Home | Main Index | Thread Index | Old Index