Source-Changes-HG archive

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

[src-draft/trunk]: src/sys/dev/usb Convert DIAGNOSTIC prints to KASSERTs.



details:   https://anonhg.NetBSD.org/src-all/rev/50d21eaa12da
branches:  trunk
changeset: 937309:50d21eaa12da
user:      Taylor R Campbell <riastradh%NetBSD.org@localhost>
date:      Sun Aug 16 00:40:14 2020 +0000

description:
Convert DIAGNOSTIC prints to KASSERTs.

diffstat:

 sys/dev/usb/ugen.c |  46 +++++++---------------------------------------
 1 files changed, 7 insertions(+), 39 deletions(-)

diffs (77 lines):

diff -r 4a92a330489c -r 50d21eaa12da sys/dev/usb/ugen.c
--- a/sys/dev/usb/ugen.c        Sun Aug 16 00:36:24 2020 +0000
+++ b/sys/dev/usb/ugen.c        Sun Aug 16 00:40:14 2020 +0000
@@ -555,12 +555,7 @@
        DPRINTFN(5, ("ugenclose: flag=%d, mode=%d, unit=%d, endpt=%d\n",
                     flag, mode, UGENUNIT(dev), endpt));
 
-#ifdef DIAGNOSTIC
-       if (!sc->sc_is_open[endpt]) {
-               printf("ugenclose: not open\n");
-               return EINVAL;
-       }
-#endif
+       KASSERT(sc->sc_is_open[endpt]);
 
        if (endpt == USB_CONTROL_ENDPOINT) {
                DPRINTFN(5, ("ugenclose: close control\n"));
@@ -628,16 +623,8 @@
        if (endpt == USB_CONTROL_ENDPOINT)
                return ENODEV;
 
-#ifdef DIAGNOSTIC
-       if (sce->edesc == NULL) {
-               printf("ugenread: no edesc\n");
-               return EIO;
-       }
-       if (sce->pipeh == NULL) {
-               printf("ugenread: no pipe\n");
-               return EIO;
-       }
-#endif
+       KASSERT(sce->edesc);
+       KASSERT(sce->pipeh);
 
        switch (sce->edesc->bmAttributes & UE_XFERTYPE) {
        case UE_INTERRUPT:
@@ -858,16 +845,8 @@
        if (endpt == USB_CONTROL_ENDPOINT)
                return ENODEV;
 
-#ifdef DIAGNOSTIC
-       if (sce->edesc == NULL) {
-               printf("ugenwrite: no edesc\n");
-               return EIO;
-       }
-       if (sce->pipeh == NULL) {
-               printf("ugenwrite: no pipe\n");
-               return EIO;
-       }
-#endif
+       KASSERT(sce->edesc);
+       KASSERT(sce->pipeh);
 
        switch (sce->edesc->bmAttributes & UE_XFERTYPE) {
        case UE_BULK:
@@ -1868,19 +1847,8 @@
 
        sce_in = &sc->sc_endpoints[UGENENDPOINT(dev)][IN];
        sce_out = &sc->sc_endpoints[UGENENDPOINT(dev)][OUT];
-       if (sce_in == NULL && sce_out == NULL)
-               return POLLERR;
-#ifdef DIAGNOSTIC
-       if (!sce_in->edesc && !sce_out->edesc) {
-               printf("ugenpoll: no edesc\n");
-               return POLLERR;
-       }
-       /* It's possible to have only one pipe open. */
-       if (!sce_in->pipeh && !sce_out->pipeh) {
-               printf("ugenpoll: no pipe\n");
-               return POLLERR;
-       }
-#endif
+       KASSERT(sce_in->edesc || sce_out->edesc);
+       KASSERT(sce_in->pipeh || sce_out->pipeh);
 
        mutex_enter(&sc->sc_lock);
        if (sce_in && sce_in->pipeh && (events & (POLLIN | POLLRDNORM)))



Home | Main Index | Thread Index | Old Index