Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/wscons Use __arraycount a bunch
details: https://anonhg.NetBSD.org/src/rev/c703d7b30c93
branches: trunk
changeset: 357265:c703d7b30c93
user: maya <maya%NetBSD.org@localhost>
date: Fri Nov 03 19:20:27 2017 +0000
description:
Use __arraycount a bunch
Also, DIAGNOSTIC panic -> KASSERT
diffstat:
sys/dev/wscons/wsemul_vt100.c | 9 +++------
sys/dev/wscons/wsemul_vt100_chars.c | 6 +++---
sys/dev/wscons/wskbdutil.c | 8 ++++----
sys/dev/wscons/wsmouse.c | 6 +++---
4 files changed, 13 insertions(+), 16 deletions(-)
diffs (120 lines):
diff -r 9902a89c4626 -r c703d7b30c93 sys/dev/wscons/wsemul_vt100.c
--- a/sys/dev/wscons/wsemul_vt100.c Fri Nov 03 18:49:37 2017 +0000
+++ b/sys/dev/wscons/wsemul_vt100.c Fri Nov 03 19:20:27 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsemul_vt100.c,v 1.40 2017/11/03 18:42:35 maya Exp $ */
+/* $NetBSD: wsemul_vt100.c,v 1.41 2017/11/03 19:20:27 maya Exp $ */
/*
* Copyright (c) 1998
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.40 2017/11/03 18:42:35 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.41 2017/11/03 19:20:27 maya Exp $");
#ifdef _KERNEL_OPT
#include "opt_wsmsgattrs.h"
@@ -1006,10 +1006,7 @@
wsemul_vt100_output_normal(edp, *data, kernel);
continue;
}
-#ifdef DIAGNOSTIC
- if (edp->state > sizeof(vt100_output) / sizeof(vt100_output[0]))
- panic("wsemul_vt100: invalid state %d", edp->state);
-#endif
+ KASSERT(edp->state < __arraycount(vt100_output) - 1);
edp->state = vt100_output[edp->state - 1](edp, *data);
}
if (vd->flags & VTFL_CURSORON)
diff -r 9902a89c4626 -r c703d7b30c93 sys/dev/wscons/wsemul_vt100_chars.c
--- a/sys/dev/wscons/wsemul_vt100_chars.c Fri Nov 03 18:49:37 2017 +0000
+++ b/sys/dev/wscons/wsemul_vt100_chars.c Fri Nov 03 19:20:27 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsemul_vt100_chars.c,v 1.14 2010/02/25 11:20:09 drochner Exp $ */
+/* $NetBSD: wsemul_vt100_chars.c,v 1.15 2017/11/03 19:20:27 maya Exp $ */
/*
* Copyright (c) 1998
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100_chars.c,v 1.14 2010/02/25 11:20:09 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100_chars.c,v 1.15 2017/11/03 19:20:27 maya Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -145,7 +145,7 @@
int i;
struct vt100base_data *vd = &edp->bd;
- KASSERT(nrc < sizeof(nrctable) / sizeof(nrctable[0]));
+ KASSERT(nrc < __arraycount(nrctable));
for (i = 0; i < 128; i++)
(*vd->emulops->mapchar)(vd->emulcookie, i, &edp->nrctab[i]);
diff -r 9902a89c4626 -r c703d7b30c93 sys/dev/wscons/wskbdutil.c
--- a/sys/dev/wscons/wskbdutil.c Fri Nov 03 18:49:37 2017 +0000
+++ b/sys/dev/wscons/wskbdutil.c Fri Nov 03 19:20:27 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wskbdutil.c,v 1.18 2010/02/05 18:26:38 drochner Exp $ */
+/* $NetBSD: wskbdutil.c,v 1.19 2017/11/03 19:20:27 maya Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wskbdutil.c,v 1.18 2010/02/05 18:26:38 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wskbdutil.c,v 1.19 2017/11/03 19:20:27 maya Exp $");
#include <sys/param.h>
#include <sys/errno.h>
@@ -271,7 +271,7 @@
{ { KS_dead_slash, KS_l }, KS_lstroke }
};
-#define COMPOSE_SIZE sizeof(compose_tab)/sizeof(compose_tab[0])
+#define COMPOSE_SIZE __arraycount(compose_tab)
static int compose_tab_inorder = 0;
@@ -504,7 +504,7 @@
mp++;
}
- if (stack_ptr == sizeof(stack)/sizeof(stack[0]))
+ if (stack_ptr == __arraycount(stack))
panic("wskbd_load_keymap: %d: recursion too deep",
mapdata->layout);
if (mp->map_size <= 0)
diff -r 9902a89c4626 -r c703d7b30c93 sys/dev/wscons/wsmouse.c
--- a/sys/dev/wscons/wsmouse.c Fri Nov 03 18:49:37 2017 +0000
+++ b/sys/dev/wscons/wsmouse.c Fri Nov 03 19:20:27 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmouse.c,v 1.66 2014/07/25 08:10:39 dholland Exp $ */
+/* $NetBSD: wsmouse.c,v 1.67 2017/11/03 19:20:27 maya Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -104,7 +104,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.66 2014/07/25 08:10:39 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.67 2017/11/03 19:20:27 maya Exp $");
#include "wsmouse.h"
#include "wsdisplay.h"
@@ -475,7 +475,7 @@
btnno = ffs(d) - 1;
KASSERT(btnno >= 0);
- if (nevents >= sizeof(events) / sizeof(events[0])) {
+ if (nevents >= __arraycount(events)) {
aprint_error_dev(sc->sc_base.me_dv,
"Event queue full (button status mb=0x%x"
" ub=0x%x)\n", mb, ub);
Home |
Main Index |
Thread Index |
Old Index