Source-Changes-HG archive

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

[src/trunk]: src/sys Introduce PR_ZERO to avoid open-coding memset()s everywh...



details:   https://anonhg.NetBSD.org/src/rev/73bfae4cc035
branches:  trunk
changeset: 839239:73bfae4cc035
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Feb 10 17:13:33 2019 +0000

description:
Introduce PR_ZERO to avoid open-coding memset()s everywhere. OK riastradh@.

diffstat:

 sys/dev/dmover/dmover_io.c       |   8 ++----
 sys/dev/ic/ncr53c9x.c            |  12 ++++------
 sys/dev/ic/wd33c93.c             |   6 ++--
 sys/dev/raidframe/rf_alloclist.c |  10 ++------
 sys/dev/raidframe/rf_callback.c  |   9 ++-----
 sys/dev/raidframe/rf_dagutils.c  |  36 ++++++-------------------------
 sys/dev/raidframe/rf_diskqueue.c |   7 ++---
 sys/dev/raidframe/rf_map.c       |  46 ++++++---------------------------------
 sys/dev/raidframe/rf_psstatus.c  |  10 ++------
 sys/kern/kern_time.c             |  10 +++-----
 sys/kern/subr_pool.c             |  11 ++++++---
 sys/kern/sys_aio.c               |   7 ++---
 sys/kern/vfs_dirhash.c           |  13 ++++------
 sys/sys/pool.h                   |   3 +-
 14 files changed, 59 insertions(+), 129 deletions(-)

diffs (truncated from 561 to 300 lines):

diff -r fef23ac3740e -r 73bfae4cc035 sys/dev/dmover/dmover_io.c
--- a/sys/dev/dmover/dmover_io.c        Sun Feb 10 11:10:34 2019 +0000
+++ b/sys/dev/dmover/dmover_io.c        Sun Feb 10 17:13:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dmover_io.c,v 1.45 2017/11/30 20:25:55 christos Exp $  */
+/*     $NetBSD: dmover_io.c,v 1.46 2019/02/10 17:13:33 christos Exp $  */
 
 /*
  * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dmover_io.c,v 1.45 2017/11/30 20:25:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dmover_io.c,v 1.46 2019/02/10 17:13:33 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -180,9 +180,7 @@
 {
        struct dmio_state *ds;
 
-       ds = pool_get(&dmio_state_pool, PR_WAITOK);
-
-       memset(ds, 0, sizeof(*ds));
+       ds = pool_get(&dmio_state_pool, PR_WAITOK | PR_ZERO);
 
        getnanotime(&ds->ds_btime);
        ds->ds_atime = ds->ds_mtime = ds->ds_btime;
diff -r fef23ac3740e -r 73bfae4cc035 sys/dev/ic/ncr53c9x.c
--- a/sys/dev/ic/ncr53c9x.c     Sun Feb 10 11:10:34 2019 +0000
+++ b/sys/dev/ic/ncr53c9x.c     Sun Feb 10 17:13:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ncr53c9x.c,v 1.150 2019/02/03 03:19:27 mrg Exp $       */
+/*     $NetBSD: ncr53c9x.c,v 1.151 2019/02/10 17:13:33 christos Exp $  */
 
 /*-
  * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.150 2019/02/03 03:19:27 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.151 2019/02/10 17:13:33 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -843,12 +843,10 @@
        int s;
 
        s = splbio();
-       ecb = pool_get(&ecb_pool, PR_NOWAIT);
+       ecb = pool_get(&ecb_pool, PR_NOWAIT | PR_ZERO);
+       if (ecb)
+               ecb->flags |= ECB_ALLOC;
        splx(s);
-       if (ecb) {
-               memset(ecb, 0, sizeof(*ecb));
-               ecb->flags |= ECB_ALLOC;
-       }
        return ecb;
 }
 
diff -r fef23ac3740e -r 73bfae4cc035 sys/dev/ic/wd33c93.c
--- a/sys/dev/ic/wd33c93.c      Sun Feb 10 11:10:34 2019 +0000
+++ b/sys/dev/ic/wd33c93.c      Sun Feb 10 17:13:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wd33c93.c,v 1.27 2018/02/08 09:05:19 dholland Exp $    */
+/*     $NetBSD: wd33c93.c,v 1.28 2019/02/10 17:13:33 christos Exp $    */
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wd33c93.c,v 1.27 2018/02/08 09:05:19 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd33c93.c,v 1.28 2019/02/10 17:13:33 christos Exp $");
 
 #include "opt_ddb.h"
 
@@ -570,7 +570,7 @@
                        panic("wd33c93_scsicmd: busy");
 
                s = splbio();
-               acb = (struct wd33c93_acb *)pool_get(&wd33c93_pool, PR_NOWAIT);
+               acb = pool_get(&wd33c93_pool, PR_NOWAIT);
                splx(s);
 
                if (acb == NULL) {
diff -r fef23ac3740e -r 73bfae4cc035 sys/dev/raidframe/rf_alloclist.c
--- a/sys/dev/raidframe/rf_alloclist.c  Sun Feb 10 11:10:34 2019 +0000
+++ b/sys/dev/raidframe/rf_alloclist.c  Sun Feb 10 17:13:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_alloclist.c,v 1.27 2019/02/09 03:33:59 christos Exp $       */
+/*     $NetBSD: rf_alloclist.c,v 1.28 2019/02/10 17:13:33 christos Exp $       */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -37,7 +37,7 @@
  ***************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_alloclist.c,v 1.27 2019/02/09 03:33:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_alloclist.c,v 1.28 2019/02/10 17:13:33 christos Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -122,9 +122,5 @@
 RF_AllocListElem_t *
 rf_real_MakeAllocList(void)
 {
-       RF_AllocListElem_t *p;
-
-       p = pool_get(&rf_pools.alloclist, PR_WAITOK);
-       memset(p, 0, sizeof(*p));
-       return (p);
+       return pool_get(&rf_pools.alloclist, PR_WAITOK | PR_ZERO);
 }
diff -r fef23ac3740e -r 73bfae4cc035 sys/dev/raidframe/rf_callback.c
--- a/sys/dev/raidframe/rf_callback.c   Sun Feb 10 11:10:34 2019 +0000
+++ b/sys/dev/raidframe/rf_callback.c   Sun Feb 10 17:13:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_callback.c,v 1.22 2009/03/15 17:17:23 cegger Exp $  */
+/*     $NetBSD: rf_callback.c,v 1.23 2019/02/10 17:13:33 christos Exp $        */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -34,7 +34,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_callback.c,v 1.22 2009/03/15 17:17:23 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_callback.c,v 1.23 2019/02/10 17:13:33 christos Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 #include <sys/pool.h>
@@ -71,10 +71,7 @@
 RF_CallbackDesc_t *
 rf_AllocCallbackDesc(void)
 {
-       RF_CallbackDesc_t *p;
-
-       p = pool_get(&rf_pools.callback, PR_WAITOK);
-       return (p);
+       return pool_get(&rf_pools.callback, PR_WAITOK);
 }
 
 void
diff -r fef23ac3740e -r 73bfae4cc035 sys/dev/raidframe/rf_dagutils.c
--- a/sys/dev/raidframe/rf_dagutils.c   Sun Feb 10 11:10:34 2019 +0000
+++ b/sys/dev/raidframe/rf_dagutils.c   Sun Feb 10 17:13:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_dagutils.c,v 1.55 2019/02/09 03:34:00 christos Exp $        */
+/*     $NetBSD: rf_dagutils.c,v 1.56 2019/02/10 17:13:33 christos Exp $        */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  *****************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_dagutils.c,v 1.55 2019/02/09 03:34:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagutils.c,v 1.56 2019/02/10 17:13:33 christos Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -254,11 +254,7 @@
 RF_DagHeader_t *
 rf_AllocDAGHeader(void)
 {
-       RF_DagHeader_t *dh;
-
-       dh = pool_get(&rf_pools.dagh, PR_WAITOK);
-       memset(dh, 0, sizeof(*dh));
-       return (dh);
+       return pool_get(&rf_pools.dagh, PR_WAITOK | PR_ZERO);
 }
 
 void
@@ -270,11 +266,7 @@
 RF_DagNode_t *
 rf_AllocDAGNode(void)
 {
-       RF_DagNode_t *node;
-
-       node = pool_get(&rf_pools.dagnode, PR_WAITOK);
-       memset(node, 0, sizeof(*node));
-       return (node);
+       return pool_get(&rf_pools.dagnode, PR_WAITOK | PR_ZERO);
 }
 
 void
@@ -292,12 +284,7 @@
 RF_DagList_t *
 rf_AllocDAGList(void)
 {
-       RF_DagList_t *dagList;
-
-       dagList = pool_get(&rf_pools.daglist, PR_WAITOK);
-       memset(dagList, 0, sizeof(*dagList));
-
-       return (dagList);
+       return pool_get(&rf_pools.daglist, PR_WAITOK | PR_ZERO);
 }
 
 void
@@ -309,11 +296,7 @@
 void *
 rf_AllocDAGPCache(void)
 {
-       void *p;
-       p = pool_get(&rf_pools.dagpcache, PR_WAITOK);
-       memset(p, 0, RF_DAGPCACHE_SIZE);
-
-       return (p);
+       return pool_get(&rf_pools.dagpcache, PR_WAITOK | PR_ZERO);
 }
 
 void
@@ -325,12 +308,7 @@
 RF_FuncList_t *
 rf_AllocFuncList(void)
 {
-       RF_FuncList_t *funcList;
-
-       funcList = pool_get(&rf_pools.funclist, PR_WAITOK);
-       memset(funcList, 0, sizeof(*funcList));
-
-       return (funcList);
+       return pool_get(&rf_pools.funclist, PR_WAITOK | PR_ZERO);
 }
 
 void
diff -r fef23ac3740e -r 73bfae4cc035 sys/dev/raidframe/rf_diskqueue.c
--- a/sys/dev/raidframe/rf_diskqueue.c  Sun Feb 10 11:10:34 2019 +0000
+++ b/sys/dev/raidframe/rf_diskqueue.c  Sun Feb 10 17:13:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_diskqueue.c,v 1.54 2019/02/09 03:34:00 christos Exp $       */
+/*     $NetBSD: rf_diskqueue.c,v 1.55 2019/02/10 17:13:33 christos Exp $       */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -66,7 +66,7 @@
  ****************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.54 2019/02/09 03:34:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.55 2019/02/10 17:13:33 christos Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -367,11 +367,10 @@
 {
        RF_DiskQueueData_t *p;
 
-       p = pool_get(&rf_pools.dqd, waitflag);
+       p = pool_get(&rf_pools.dqd, waitflag | PR_ZERO);
        if (p == NULL)
                return (NULL);
 
-       memset(p, 0, sizeof(*p));
        if (waitflag == PR_WAITOK) {
                p->bp = getiobuf(NULL, true);
        } else {
diff -r fef23ac3740e -r 73bfae4cc035 sys/dev/raidframe/rf_map.c
--- a/sys/dev/raidframe/rf_map.c        Sun Feb 10 11:10:34 2019 +0000
+++ b/sys/dev/raidframe/rf_map.c        Sun Feb 10 17:13:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_map.c,v 1.48 2019/02/09 03:34:00 christos Exp $     */
+/*     $NetBSD: rf_map.c,v 1.49 2019/02/10 17:13:33 christos Exp $     */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  **************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_map.c,v 1.48 2019/02/09 03:34:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_map.c,v 1.49 2019/02/10 17:13:33 christos Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -376,12 +376,7 @@
 RF_AccessStripeMapHeader_t *
 rf_AllocAccessStripeMapHeader(void)
 {
-       RF_AccessStripeMapHeader_t *p;
-
-       p = pool_get(&rf_pools.asm_hdr, PR_WAITOK);
-       memset(p, 0, sizeof(*p));
-
-       return (p);
+       return pool_get(&rf_pools.asm_hdr, PR_WAITOK | PR_ZERO);
 }
 
 void
@@ -394,12 +389,7 @@
 RF_VoidFunctionPointerListElem_t *
 rf_AllocVFPListElem(void)



Home | Main Index | Thread Index | Old Index