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 DIAGNOSTIC prints to KASSERTs.
details: https://anonhg.NetBSD.org/src/rev/1278c8bb64f1
branches: trunk
changeset: 974891:1278c8bb64f1
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Aug 16 02:34:54 2020 +0000
description:
Convert DIAGNOSTIC prints to KASSERTs.
diffstat:
sys/dev/usb/ugen.c | 50 +++++++++-----------------------------------------
1 files changed, 9 insertions(+), 41 deletions(-)
diffs (92 lines):
diff -r 39f623f93d97 -r 1278c8bb64f1 sys/dev/usb/ugen.c
--- a/sys/dev/usb/ugen.c Sun Aug 16 02:34:20 2020 +0000
+++ b/sys/dev/usb/ugen.c Sun Aug 16 02:34:54 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ugen.c,v 1.153 2020/08/16 02:34:20 riastradh Exp $ */
+/* $NetBSD: ugen.c,v 1.154 2020/08/16 02:34:54 riastradh Exp $ */
/*
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.153 2020/08/16 02:34:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.154 2020/08/16 02:34:54 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -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