From 85882e82c16b2d91f469b88064ca6c3ba961c22c Mon Sep 17 00:00:00 2001 From: jasper Date: Sun, 13 Jul 2014 12:11:01 +0000 Subject: [PATCH] use nitems() instead of handrolling something identical ok mpi@ sthen@ --- sys/arch/alpha/alpha/db_interface.c | 4 ++-- sys/arch/amd64/amd64/amd64_mem.c | 8 +++----- sys/arch/amd64/amd64/amd64errata.c | 4 ++-- sys/arch/amd64/amd64/bios.c | 4 ++-- sys/arch/amd64/amd64/db_trace.c | 5 ++--- sys/arch/amd64/amd64/identcpu.c | 26 +++++++++---------------- sys/arch/amd64/amd64/machdep.c | 4 ++-- sys/arch/amd64/amd64/trap.c | 4 ++-- sys/arch/arm/arm/db_interface.c | 4 ++-- sys/arch/hppa/hppa/db_interface.c | 4 ++-- sys/arch/hppa64/hppa64/db_interface.c | 4 ++-- sys/arch/i386/i386/db_trace.c | 4 ++-- sys/arch/i386/i386/i686_mem.c | 8 +++----- sys/arch/m88k/m88k/db_trace.c | 4 ++-- sys/arch/mips64/mips64/db_machdep.c | 4 ++-- sys/arch/powerpc/ddb/db_trace.c | 4 ++-- sys/arch/sh/sh/db_trace.c | 5 ++--- sys/arch/sparc/sparc/db_interface.c | 4 ++-- sys/arch/sparc64/sparc64/db_interface.c | 4 ++-- sys/arch/vax/vax/db_machdep.c | 4 ++-- 20 files changed, 49 insertions(+), 63 deletions(-) diff --git a/sys/arch/alpha/alpha/db_interface.c b/sys/arch/alpha/alpha/db_interface.c index aa1db0ecaed..0c61db9967f 100644 --- a/sys/arch/alpha/alpha/db_interface.c +++ b/sys/arch/alpha/alpha/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.20 2014/03/29 18:09:28 guenther Exp $ */ +/* $OpenBSD: db_interface.c,v 1.21 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: db_interface.c,v 1.8 1999/10/12 17:08:57 jdolecek Exp $ */ /* @@ -131,7 +131,7 @@ struct db_variable db_regs[] = { { "ai", &ddb_regs.tf_regs[FRAME_T11], FCN_NULL }, { "pv", &ddb_regs.tf_regs[FRAME_T12], FCN_NULL }, }; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable *db_eregs = db_regs + nitems(db_regs); /* * ddb_trap - field a kernel trap diff --git a/sys/arch/amd64/amd64/amd64_mem.c b/sys/arch/amd64/amd64/amd64_mem.c index d709b9cbafe..ce0fd6d7727 100644 --- a/sys/arch/amd64/amd64/amd64_mem.c +++ b/sys/arch/amd64/amd64/amd64_mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: amd64_mem.c,v 1.7 2013/08/24 04:26:15 mlarkin Exp $ */ +/* $OpenBSD: amd64_mem.c,v 1.8 2014/07/13 12:11:01 jasper Exp $ */ /* * Copyright (c) 1999 Michael Smith * All rights reserved. @@ -106,12 +106,10 @@ int mtrrtomrt[] = { MDF_WRITEBACK }; -#define MTRRTOMRTLEN (sizeof(mtrrtomrt) / sizeof(mtrrtomrt[0])) - int mtrr2mrt(int val) { - if (val < 0 || val >= MTRRTOMRTLEN) + if (val < 0 || val >= nitems(mtrrtomrt)) return MDF_UNKNOWN; return mtrrtomrt[val]; } @@ -249,7 +247,7 @@ mtrrtype(u_int64_t flags) flags &= MDF_ATTRMASK; - for (i = 0; i < MTRRTOMRTLEN; i++) { + for (i = 0; i < nitems(mtrrtomrt); i++) { if (mtrrtomrt[i] == MDF_UNKNOWN) continue; if (flags == mtrrtomrt[i]) diff --git a/sys/arch/amd64/amd64/amd64errata.c b/sys/arch/amd64/amd64/amd64errata.c index cfc5654a458..b1123e1c12b 100644 --- a/sys/arch/amd64/amd64/amd64errata.c +++ b/sys/arch/amd64/amd64/amd64errata.c @@ -1,4 +1,4 @@ -/* $OpenBSD: amd64errata.c,v 1.6 2013/12/07 01:43:50 brad Exp $ */ +/* $OpenBSD: amd64errata.c,v 1.7 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: errata.c,v 1.6 2007/02/05 21:05:45 ad Exp $ */ /*- @@ -312,7 +312,7 @@ amd64_errata(struct cpu_info *ci) } } - ex = errata + sizeof(errata) / sizeof(errata[0]); + ex = errata + nitems(errata); /* Reset e_reporteds (for multiple CPUs) */ for (e = errata; e < ex; e++) diff --git a/sys/arch/amd64/amd64/bios.c b/sys/arch/amd64/amd64/bios.c index cbeedf44020..54d41042bb9 100644 --- a/sys/arch/amd64/amd64/bios.c +++ b/sys/arch/amd64/amd64/bios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bios.c,v 1.26 2013/11/19 04:12:17 guenther Exp $ */ +/* $OpenBSD: bios.c,v 1.27 2014/07/13 12:11:01 jasper Exp $ */ /* * Copyright (c) 2006 Gordon Willem Klok * @@ -314,7 +314,7 @@ fixstring(char *s) char *p, *e; int i; - for (i = 0; i < sizeof(smbios_uninfo)/sizeof(smbios_uninfo[0]); i++) + for (i = 0; i < nitems(smbios_uninfo); i++) if ((strncasecmp(s, smbios_uninfo[i], strlen(smbios_uninfo[i])))==0) return NULL; diff --git a/sys/arch/amd64/amd64/db_trace.c b/sys/arch/amd64/amd64/db_trace.c index b784e72172f..1b45a85ac9d 100644 --- a/sys/arch/amd64/amd64/db_trace.c +++ b/sys/arch/amd64/amd64/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.7 2010/09/27 10:08:28 mikeb Exp $ */ +/* $OpenBSD: db_trace.c,v 1.8 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: db_trace.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */ /* @@ -79,8 +79,7 @@ struct db_variable db_regs[] = { { "rsp", dbreg(rsp), db_x86_64_regop }, { "ss", dbreg(ss), db_x86_64_regop }, }; -struct db_variable * db_eregs = - db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable * db_eregs = db_regs + nitems(db_regs); static int db_x86_64_regop(struct db_variable *vp, db_expr_t *val, int opcode) diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index 3bde63ec12f..3f8d5146b7f 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identcpu.c,v 1.53 2014/07/03 21:15:28 matthew Exp $ */ +/* $OpenBSD: identcpu.c,v 1.54 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /* @@ -385,7 +385,7 @@ identifycpu(struct cpu_info *ci) u_int32_t dummy, val, pnfeatset; u_int32_t brand[12]; char mycpu_model[48]; - int i, max; + int i; char *brandstr_from, *brandstr_to; int skipspace; @@ -477,37 +477,29 @@ identifycpu(struct cpu_info *ci) printf("\n%s: ", ci->ci_dev->dv_xname); - max = sizeof(cpu_cpuid_features) / sizeof(cpu_cpuid_features[0]); - for (i = 0; i < max; i++) + for (i = 0; i < nitems(cpu_cpuid_features); i++) if (ci->ci_feature_flags & cpu_cpuid_features[i].bit) printf("%s%s", i? "," : "", cpu_cpuid_features[i].str); - max = sizeof(cpu_cpuid_ecxfeatures) / sizeof(cpu_cpuid_ecxfeatures[0]); - for (i = 0; i < max; i++) + for (i = 0; i < nitems(cpu_cpuid_ecxfeatures); i++) if (cpu_ecxfeature & cpu_cpuid_ecxfeatures[i].bit) printf(",%s", cpu_cpuid_ecxfeatures[i].str); - max = sizeof(cpu_ecpuid_features) / sizeof(cpu_ecpuid_features[0]); - for (i = 0; i < max; i++) + for (i = 0; i < nitems(cpu_ecpuid_features); i++) if (ci->ci_feature_eflags & cpu_ecpuid_features[i].bit) printf(",%s", cpu_ecpuid_features[i].str); - max = sizeof(cpu_ecpuid_ecxfeatures) / sizeof(cpu_ecpuid_ecxfeatures[0]); - for (i = 0; i < max; i++) + for (i = 0; i < nitems(cpu_ecpuid_ecxfeatures); i++) if (ecpu_ecxfeature & cpu_ecpuid_ecxfeatures[i].bit) printf(",%s", cpu_ecpuid_ecxfeatures[i].str); - max = sizeof(cpu_cpuid_perf_eax) / sizeof(cpu_cpuid_perf_eax[0]); - for (i = 0; i < max; i++) + for (i = 0; i < nitems(cpu_cpuid_perf_eax); i++) if (cpu_perf_eax & cpu_cpuid_perf_eax[i].bit) printf(",%s", cpu_cpuid_perf_eax[i].str); - max = sizeof(cpu_cpuid_apmi_edx) / sizeof(cpu_cpuid_apmi_edx[0]); - for (i = 0; i < max; i++) + for (i = 0; i < nitems(cpu_cpuid_apmi_edx); i++) if (cpu_apmi_edx & cpu_cpuid_apmi_edx[i].bit) printf(",%s", cpu_cpuid_apmi_edx[i].str); if (cpuid_level >= 0x07) { /* "Structured Extended Feature Flags" */ CPUID_LEAF(0x7, 0, dummy, ci->ci_feature_sefflags, dummy, dummy); - max = sizeof(cpu_seff0_ebxfeatures) / - sizeof(cpu_seff0_ebxfeatures[0]); - for (i = 0; i < max; i++) + for (i = 0; i < nitems(cpu_seff0_ebxfeatures); i++) if (ci->ci_feature_sefflags & cpu_seff0_ebxfeatures[i].bit) printf(",%s", cpu_seff0_ebxfeatures[i].str); diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index d42dd320596..af754189a7b 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.185 2014/07/11 22:28:05 uebayasi Exp $ */ +/* $OpenBSD: machdep.c,v 1.186 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -1862,7 +1862,7 @@ getbootinfo(char *bootinfo, int bootinfo_size) int unit = minor(cdp->consdev); int consaddr = cdp->consaddr; if (consaddr == -1 && unit >= 0 && - unit < (sizeof(ports)/sizeof(ports[0]))) + unit < nitems(ports)) consaddr = ports[unit]; if (major(cdp->consdev) == 8 && consaddr != -1) { diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 67e2ec884a3..8ec6571fd0e 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.41 2014/07/09 07:29:00 guenther Exp $ */ +/* $OpenBSD: trap.c,v 1.42 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */ /*- @@ -124,7 +124,7 @@ const char *trap_type[] = { "SSE FP exception", /* 19 T_XMM */ "reserved trap", /* 20 T_RESERVED */ }; -int trap_types = sizeof trap_type / sizeof trap_type[0]; +int trap_types = nitems(trap_type); #ifdef DEBUG int trapdebug = 0; diff --git a/sys/arch/arm/arm/db_interface.c b/sys/arch/arm/arm/db_interface.c index 00030940417..c934a3796cc 100644 --- a/sys/arch/arm/arm/db_interface.c +++ b/sys/arch/arm/arm/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.7 2013/04/30 11:50:47 patrick Exp $ */ +/* $OpenBSD: db_interface.c,v 1.8 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: db_interface.c,v 1.34 2003/10/26 23:11:15 chris Exp $ */ /* @@ -90,7 +90,7 @@ struct db_variable db_regs[] = { extern label_t *db_recover; -struct db_variable * db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable * db_eregs = db_regs + nitems(db_regs); int db_active = 0; diff --git a/sys/arch/hppa/hppa/db_interface.c b/sys/arch/hppa/hppa/db_interface.c index 1b2c793c943..4276a9a1c3b 100644 --- a/sys/arch/hppa/hppa/db_interface.c +++ b/sys/arch/hppa/hppa/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.34 2014/03/29 18:09:29 guenther Exp $ */ +/* $OpenBSD: db_interface.c,v 1.35 2014/07/13 12:11:01 jasper Exp $ */ /* * Copyright (c) 1999-2003 Michael Shalayeff @@ -121,7 +121,7 @@ struct db_variable db_regs[] = { { "cr28", (long *)&ddb_regs.tf_cr28, FCN_NULL }, { "cr30", (long *)&ddb_regs.tf_cr30, FCN_NULL }, }; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable *db_eregs = db_regs + nitems(db_regs); int db_active = 0; void diff --git a/sys/arch/hppa64/hppa64/db_interface.c b/sys/arch/hppa64/hppa64/db_interface.c index 4dd1f4e7485..4aa012b103d 100644 --- a/sys/arch/hppa64/hppa64/db_interface.c +++ b/sys/arch/hppa64/hppa64/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.3 2014/03/29 18:09:29 guenther Exp $ */ +/* $OpenBSD: db_interface.c,v 1.4 2014/07/13 12:11:01 jasper Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -107,7 +107,7 @@ struct db_variable db_regs[] = { { "pidr1", (long *)&ddb_regs.tf_pidr1, FCN_NULL }, { "pidr2", (long *)&ddb_regs.tf_pidr2, FCN_NULL }, }; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable *db_eregs = db_regs + nitems(db_regs); int db_active = 0; void diff --git a/sys/arch/i386/i386/db_trace.c b/sys/arch/i386/i386/db_trace.c index 8bff4455178..291b9e9cb0f 100644 --- a/sys/arch/i386/i386/db_trace.c +++ b/sys/arch/i386/i386/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.13 2006/11/28 18:56:17 uwe Exp $ */ +/* $OpenBSD: db_trace.c,v 1.14 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: db_trace.c,v 1.18 1996/05/03 19:42:01 christos Exp $ */ /* @@ -61,7 +61,7 @@ struct db_variable db_regs[] = { { "esp", (long *)&ddb_regs.tf_esp, FCN_NULL }, { "ss", (long *)&ddb_regs.tf_ss, FCN_NULL }, }; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable *db_eregs = db_regs + nitems(db_regs); /* * Stack trace. diff --git a/sys/arch/i386/i386/i686_mem.c b/sys/arch/i386/i386/i686_mem.c index b2a4786db36..0a0f4c07e42 100644 --- a/sys/arch/i386/i386/i686_mem.c +++ b/sys/arch/i386/i386/i686_mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i686_mem.c,v 1.15 2013/08/24 04:26:16 mlarkin Exp $ */ +/* $OpenBSD: i686_mem.c,v 1.16 2014/07/13 12:11:01 jasper Exp $ */ /* * Copyright (c) 1999 Michael Smith * All rights reserved. @@ -106,12 +106,10 @@ int mtrrtomrt[] = { MDF_WRITEBACK }; -#define MTRRTOMRTLEN (sizeof(mtrrtomrt) / sizeof(mtrrtomrt[0])) - int mtrr2mrt(int val) { - if (val < 0 || val >= MTRRTOMRTLEN) + if (val < 0 || val >= nitems(mtrrtomrt)) return MDF_UNKNOWN; return mtrrtomrt[val]; } @@ -249,7 +247,7 @@ mtrrtype(u_int64_t flags) flags &= MDF_ATTRMASK; - for (i = 0; i < MTRRTOMRTLEN; i++) { + for (i = 0; i < nitems(mtrrtomrt); i++) { if (mtrrtomrt[i] == MDF_UNKNOWN) continue; if (flags == mtrrtomrt[i]) diff --git a/sys/arch/m88k/m88k/db_trace.c b/sys/arch/m88k/m88k/db_trace.c index 10b3d4190a4..e63b26fc693 100644 --- a/sys/arch/m88k/m88k/db_trace.c +++ b/sys/arch/m88k/m88k/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.12 2011/01/03 05:58:19 miod Exp $ */ +/* $OpenBSD: db_trace.c,v 1.13 2014/07/13 12:11:01 jasper Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1991 Carnegie Mellon University @@ -116,7 +116,7 @@ struct db_variable db_regs[] = { }; #undef N -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable *db_eregs = db_regs + nitems(db_regs); #define TRASHES 0x001 /* clobbers instruction field D */ #define STORE 0x002 /* does a store to S1+IMM16 */ diff --git a/sys/arch/mips64/mips64/db_machdep.c b/sys/arch/mips64/mips64/db_machdep.c index b223f449150..aab4523738e 100644 --- a/sys/arch/mips64/mips64/db_machdep.c +++ b/sys/arch/mips64/mips64/db_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_machdep.c,v 1.41 2014/07/09 12:58:08 miod Exp $ */ +/* $OpenBSD: db_machdep.c,v 1.42 2014/07/13 12:11:01 jasper Exp $ */ /* * Copyright (c) 1998-2003 Opsycon AB (www.opsycon.se) @@ -125,7 +125,7 @@ struct db_variable db_regs[] = { { "cs", (long *)&ddb_regs.cause, FCN_NULL }, { "pc", (long *)&ddb_regs.pc, FCN_NULL }, }; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable *db_eregs = db_regs + nitems(db_regs); extern label_t *db_recover; diff --git a/sys/arch/powerpc/ddb/db_trace.c b/sys/arch/powerpc/ddb/db_trace.c index 73bff090fa5..e233eca7c0f 100644 --- a/sys/arch/powerpc/ddb/db_trace.c +++ b/sys/arch/powerpc/ddb/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.4 2003/10/15 01:06:13 drahn Exp $ */ +/* $OpenBSD: db_trace.c,v 1.5 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: db_trace.c,v 1.15 1996/02/22 23:23:41 gwr Exp $ */ /* @@ -86,7 +86,7 @@ struct db_variable db_regs[] = { { "msr", (long *)&(DDB_REGS->tf.srr1), FCN_NULL }, }; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable *db_eregs = db_regs + nitems(db_regs); extern label_t *db_recover; diff --git a/sys/arch/sh/sh/db_trace.c b/sys/arch/sh/sh/db_trace.c index 311b6161e48..ad0839dfe6f 100644 --- a/sys/arch/sh/sh/db_trace.c +++ b/sys/arch/sh/sh/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.5 2008/06/22 21:02:11 miod Exp $ */ +/* $OpenBSD: db_trace.c,v 1.6 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: db_trace.c,v 1.19 2006/01/21 22:10:59 uwe Exp $ */ /*- @@ -71,8 +71,7 @@ struct db_variable db_regs[] = { { "macl", (long *)&ddb_regs.tf_macl, FCN_NULL }, }; -struct db_variable *db_eregs = - db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable *db_eregs = db_regs + nitems(db_regs); void db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, diff --git a/sys/arch/sparc/sparc/db_interface.c b/sys/arch/sparc/sparc/db_interface.c index dd0ced0f574..3affa5f1598 100644 --- a/sys/arch/sparc/sparc/db_interface.c +++ b/sys/arch/sparc/sparc/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.13 2010/06/29 21:28:11 miod Exp $ */ +/* $OpenBSD: db_interface.c,v 1.14 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: db_interface.c,v 1.18 1997/09/01 00:16:31 pk Exp $ */ /* @@ -151,7 +151,7 @@ struct db_variable db_regs[] = { { "i6", (long *)&DDB_FR->fr_arg[6], FCN_NULL, }, { "i7", (long *)&DDB_FR->fr_arg[7], FCN_NULL, }, }; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable *db_eregs = db_regs + nitems(db_regs); extern label_t *db_recover; diff --git a/sys/arch/sparc64/sparc64/db_interface.c b/sys/arch/sparc64/sparc64/db_interface.c index 0eaf21a980e..c34b23ea123 100644 --- a/sys/arch/sparc64/sparc64/db_interface.c +++ b/sys/arch/sparc64/sparc64/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.35 2014/05/10 18:46:20 kettenis Exp $ */ +/* $OpenBSD: db_interface.c,v 1.36 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: db_interface.c,v 1.61 2001/07/31 06:55:47 eeh Exp $ */ /* @@ -195,7 +195,7 @@ struct db_variable db_regs[] = { { "gsr", (long *)&DDB_FP->fs_gsr, FCN_NULL, }, }; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable *db_eregs = db_regs + nitems(db_regs); extern label_t *db_recover; diff --git a/sys/arch/vax/vax/db_machdep.c b/sys/arch/vax/vax/db_machdep.c index 90be83f3809..cecb4323e1e 100644 --- a/sys/arch/vax/vax/db_machdep.c +++ b/sys/arch/vax/vax/db_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_machdep.c,v 1.18 2008/03/30 18:24:04 miod Exp $ */ +/* $OpenBSD: db_machdep.c,v 1.19 2014/07/13 12:11:01 jasper Exp $ */ /* $NetBSD: db_machdep.c,v 1.17 1999/06/20 00:58:23 ragge Exp $ */ /* @@ -227,7 +227,7 @@ struct db_variable db_regs[] = { {"pc", (long *)&ddb_regs.pc, FCN_NULL}, {"psl", (long *)&ddb_regs.psl, FCN_NULL}, }; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); +struct db_variable *db_eregs = db_regs + nitems(db_regs); #define IN_USERLAND(x) (((u_int)(x) & 0x80000000) == 0) -- 2.20.1