Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Just use KASSERTMSG and panic. No need for custom w...



details:   https://anonhg.NetBSD.org/src/rev/d0901c33c5ba
branches:  trunk
changeset: 1005598:d0901c33c5ba
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Dec 14 16:58:38 2019 +0000

description:
Just use KASSERTMSG and panic.  No need for custom wrappers.

diffstat:

 sys/dev/cgd.c        |  26 +++++++++-----------------
 sys/dev/cgd_crypto.c |  18 ++++++------------
 2 files changed, 15 insertions(+), 29 deletions(-)

diffs (131 lines):

diff -r a9c6f9063b03 -r d0901c33c5ba sys/dev/cgd.c
--- a/sys/dev/cgd.c     Sat Dec 14 16:58:25 2019 +0000
+++ b/sys/dev/cgd.c     Sat Dec 14 16:58:38 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.117 2019/12/08 12:14:40 mlelstv Exp $ */
+/* $NetBSD: cgd.c,v 1.118 2019/12/14 16:58:38 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.117 2019/12/08 12:14:40 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.118 2019/12/14 16:58:38 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -262,14 +262,6 @@
 #define DPRINTF_FOLLOW(y)
 #endif
 
-#ifdef DIAGNOSTIC
-#define DIAGPANIC(x)           panic x
-#define DIAGCONDPANIC(x,y)     if (x) panic y
-#else
-#define DIAGPANIC(x)
-#define DIAGCONDPANIC(x,y)
-#endif
-
 /* Global variables */
 
 /* Utility Functions */
@@ -1047,15 +1039,15 @@
 
        DPRINTF_FOLLOW(("cgd_cipher() dir=%d\n", dir));
 
-       DIAGCONDPANIC(len % blocksize != 0,
-           ("cgd_cipher: len %% blocksize != 0"));
+       KASSERTMSG(len % blocksize == 0,
+           "cgd_cipher: len %% blocksize != 0");
 
        /* ensure that sizeof(daddr_t) <= blocksize (for encblkno IVing) */
-       DIAGCONDPANIC(sizeof(daddr_t) > blocksize,
-           ("cgd_cipher: sizeof(daddr_t) > blocksize"));
+       KASSERTMSG(sizeof(daddr_t) <= blocksize,
+           "cgd_cipher: sizeof(daddr_t) > blocksize");
 
-       DIAGCONDPANIC(blocksize > CGD_MAXBLOCKSIZE,
-           ("cgd_cipher: blocksize > CGD_MAXBLOCKSIZE"));
+       KASSERTMSG(blocksize <= CGD_MAXBLOCKSIZE,
+           "cgd_cipher: blocksize > CGD_MAXBLOCKSIZE");
 
        dstuio.uio_iov = dstiov;
        dstuio.uio_iovcnt = 1;
@@ -1098,7 +1090,7 @@
 {
        char    *c = buf;
 
-       DIAGCONDPANIC(len < 0, ("hexprint: called with len < 0"));
+       KASSERTMSG(len >= 0, "hexprint: called with len < 0");
        printf("%s: len=%06d 0x", start, len);
        while (len--)
                printf("%02x", (unsigned char) *c++);
diff -r a9c6f9063b03 -r d0901c33c5ba sys/dev/cgd_crypto.c
--- a/sys/dev/cgd_crypto.c      Sat Dec 14 16:58:25 2019 +0000
+++ b/sys/dev/cgd_crypto.c      Sat Dec 14 16:58:38 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd_crypto.c,v 1.16 2019/09/26 11:47:38 gutteridge Exp $ */
+/* $NetBSD: cgd_crypto.c,v 1.17 2019/12/14 16:58:38 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd_crypto.c,v 1.16 2019/09/26 11:47:38 gutteridge Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd_crypto.c,v 1.17 2019/12/14 16:58:38 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -49,12 +49,6 @@
 #include <crypto/des/des.h>
 #include <crypto/blowfish/blowfish.h>
 
-#ifdef DIAGNOSTIC
-#define DIAGPANIC(x)   panic x
-#else
-#define DIAGPANIC(x)
-#endif
-
 /*
  * The general framework provides only one generic function.
  * It takes the name of an algorithm and returns a struct cryptfuncs *
@@ -296,7 +290,7 @@
                cgd_cipher_uio(&encd, aes_cbc_dec_int, dstuio, srcuio);
                break;
        default:
-               DIAGPANIC(("%s: unrecognised direction %d", __func__, dir));
+               panic("%s: unrecognised direction %d", __func__, dir);
        }
 }
 
@@ -396,7 +390,7 @@
                cgd_cipher_uio(&encd, aes_xts_dec_int, dstuio, srcuio);
                break;
        default:
-               DIAGPANIC(("%s: unrecognised direction %d", __func__, dir));
+               panic("%s: unrecognised direction %d", __func__, dir);
        }
 }
 
@@ -511,7 +505,7 @@
                cgd_cipher_uio(&ce, c3des_cbc_dec_int, dstuio, srcuio);
                break;
        default:
-               DIAGPANIC(("%s: unrecognised direction %d", __func__, dir));
+               panic("%s: unrecognised direction %d", __func__, dir);
        }
 }
 
@@ -609,7 +603,7 @@
                cgd_cipher_uio(&be, bf_cbc_dec_int, dstuio, srcuio);
                break;
        default:
-               DIAGPANIC(("%s: unrecognised direction %d", __func__, dir));
+               panic("%s: unrecognised direction %d", __func__, dir);
        }
 
 }



Home | Main Index | Thread Index | Old Index