Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netipsec Use __arraycount (NFC)
details: https://anonhg.NetBSD.org/src/rev/ab608d271cf9
branches: trunk
changeset: 353798:ab608d271cf9
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Tue May 23 09:08:45 2017 +0000
description:
Use __arraycount (NFC)
diffstat:
sys/netipsec/ipsec.c | 8 ++++----
sys/netipsec/key.c | 14 +++++++-------
2 files changed, 11 insertions(+), 11 deletions(-)
diffs (92 lines):
diff -r 1e8bb0588346 -r ab608d271cf9 sys/netipsec/ipsec.c
--- a/sys/netipsec/ipsec.c Tue May 23 08:54:38 2017 +0000
+++ b/sys/netipsec/ipsec.c Tue May 23 09:08:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec.c,v 1.93 2017/05/23 04:26:08 ozaki-r Exp $ */
+/* $NetBSD: ipsec.c,v 1.94 2017/05/23 09:08:45 ozaki-r Exp $ */
/* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $ */
/* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.93 2017/05/23 04:26:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.94 2017/05/23 09:08:45 ozaki-r Exp $");
/*
* IPsec controller part.
@@ -214,7 +214,7 @@
KASSERT(IPSEC_DIR_IS_VALID(dir));
KASSERT(pcbsp != NULL);
- KASSERT(dir < sizeof(pcbsp->sp_cache)/sizeof(pcbsp->sp_cache[0]));
+ KASSERT(dir < __arraycount(pcbsp->sp_cache));
KASSERT(inph_locked(pcbsp->sp_inph));
/* SPD table change invalidate all the caches. */
@@ -271,7 +271,7 @@
{
KASSERT(IPSEC_DIR_IS_INOROUT(dir));
- KASSERT(dir < sizeof(pcbsp->sp_cache)/sizeof(pcbsp->sp_cache[0]));
+ KASSERT(dir < __arraycount(pcbsp->sp_cache));
KASSERT(inph_locked(pcbsp->sp_inph));
if (pcbsp->sp_cache[dir].cachesp)
diff -r 1e8bb0588346 -r ab608d271cf9 sys/netipsec/key.c
--- a/sys/netipsec/key.c Tue May 23 08:54:38 2017 +0000
+++ b/sys/netipsec/key.c Tue May 23 09:08:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.c,v 1.139 2017/05/23 04:26:08 ozaki-r Exp $ */
+/* $NetBSD: key.c,v 1.140 2017/05/23 09:08:45 ozaki-r Exp $ */
/* $FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $ */
/* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.139 2017/05/23 04:26:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.140 2017/05/23 09:08:45 ozaki-r Exp $");
/*
* This code is referd to RFC 2367
@@ -3478,7 +3478,7 @@
goto fail;
result = m;
- for (i = sizeof(dumporder)/sizeof(dumporder[0]) - 1; i >= 0; i--) {
+ for (i = __arraycount(dumporder) - 1; i >= 0; i--) {
m = NULL;
p = NULL;
switch (dumporder[i]) {
@@ -6615,7 +6615,7 @@
KASSERT(mhp->msg != NULL);
/* check for invalid register message */
- if (mhp->msg->sadb_msg_satype >= sizeof(regtree)/sizeof(regtree[0]))
+ if (mhp->msg->sadb_msg_satype >= __arraycount(regtree))
return key_senderror(so, m, EINVAL);
/* When SATYPE_UNSPEC is specified, only return sabd_supported. */
@@ -7470,7 +7470,7 @@
*/
}
- if (msg->sadb_msg_type >= sizeof(key_typesw)/sizeof(key_typesw[0]) ||
+ if (msg->sadb_msg_type >= __arraycount(key_typesw) ||
key_typesw[msg->sadb_msg_type] == NULL) {
PFKEY_STATINC(PFKEY_STAT_OUT_INVMSGTYPE);
error = EINVAL;
@@ -7619,8 +7619,8 @@
return EINVAL;
/* if it does not match minimum/maximum length, bail */
- if (ext->sadb_ext_type >= sizeof(minsize) / sizeof(minsize[0]) ||
- ext->sadb_ext_type >= sizeof(maxsize) / sizeof(maxsize[0]))
+ if (ext->sadb_ext_type >= __arraycount(minsize) ||
+ ext->sadb_ext_type >= __arraycount(maxsize))
return EINVAL;
if (!minsize[ext->sadb_ext_type] || len < minsize[ext->sadb_ext_type])
return EINVAL;
Home |
Main Index |
Thread Index |
Old Index