Source-Changes-HG archive

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

[src/trunk]: src/sys/dev sequencer(4): Convert some #if DIAGNOSTIC to asserti...



details:   https://anonhg.NetBSD.org/src/rev/7bbc38e61b85
branches:  trunk
changeset: 365249:7bbc38e61b85
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Apr 16 11:13:01 2022 +0000

description:
sequencer(4): Convert some #if DIAGNOSTIC to assertions.

diffstat:

 sys/dev/sequencer.c |  19 ++++++-------------
 1 files changed, 6 insertions(+), 13 deletions(-)

diffs (48 lines):

diff -r 3c890ad8be5a -r 7bbc38e61b85 sys/dev/sequencer.c
--- a/sys/dev/sequencer.c       Sat Apr 16 11:12:21 2022 +0000
+++ b/sys/dev/sequencer.c       Sat Apr 16 11:13:01 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sequencer.c,v 1.77 2022/04/16 11:12:21 riastradh Exp $ */
+/*     $NetBSD: sequencer.c,v 1.78 2022/04/16 11:13:01 riastradh Exp $ */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sequencer.c,v 1.77 2022/04/16 11:12:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sequencer.c,v 1.78 2022/04/16 11:13:01 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "sequencer.h"
@@ -243,12 +243,10 @@
 {
        struct sequencer_softc *sc;
 
-       if (unit < 0) {
-#ifdef DIAGNOSTIC
-               panic("%s: unit %d!", __func__, unit);
-#endif
+       KASSERTMSG(unit >= 0, "unit=%d", unit);
+
+       if (unit < 0)
                return NULL;
-       }
 
        mutex_enter(&sequencer_lock);
        LIST_FOREACH(sc, &sequencers, sc_link) {
@@ -1305,12 +1303,7 @@
        struct sysex_info sysex;
        u_int dev;
 
-#ifdef DIAGNOSTIC
-       if (sizeof(seq_event_rec) != SEQ_SYSEX_HDRSIZE) {
-               printf("seq_do_fullsize: sysex size ??\n");
-               return EINVAL;
-       }
-#endif
+       CTASSERT(sizeof(seq_event_rec) == SEQ_SYSEX_HDRSIZE);
        memcpy(&sysex, b, sizeof(*b));
        dev = sysex.device_no;
        if (/* dev < 0 || */ dev >= sc->nmidi)



Home | Main Index | Thread Index | Old Index