From e92b9f84c11f6298401a0e73b09cf36a982f4fbe Mon Sep 17 00:00:00 2001 From: Frank Zago Date: Mon, 7 Jul 2014 17:39:13 -0500 Subject: [PATCH] LU-5304: do not memset after LIBCFS_ALLOC LIBCFS_ALLOC already zero out the memory allocated, so there is no need to zero out the memory again. Signed-off-by: Frank Zago Change-Id: Iac0210eefa999e6ef52bb16cacc67854ef5a8cfa Reviewed-on: http://review.whamcloud.com/11012 Reviewed-by: Patrick Farrell Tested-by: Jenkins Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/params_tree.h | 7 ++++--- libcfs/libcfs/linux/linux-tcpip.c | 2 -- lnet/klnds/o2iblnd/o2iblnd.c | 2 -- lnet/lnet/api-ni.c | 1 - lnet/lnet/router.c | 1 - 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/libcfs/include/libcfs/params_tree.h b/libcfs/include/libcfs/params_tree.h index 238408c..0bfbdf7 100644 --- a/libcfs/include/libcfs/params_tree.h +++ b/libcfs/include/libcfs/params_tree.h @@ -179,13 +179,14 @@ seq_open(struct file *file, const struct seq_operations *fops) { struct seq_file *p = file->param_private; - if (!p) { + if (p == NULL) { LIBCFS_ALLOC(p, sizeof(*p)); - if (!p) + if (p == NULL) return -ENOMEM; file->param_private = p; + } else { + memset(p, 0, sizeof(*p)); } - memset(p, 0, sizeof(*p)); p->op = fops; return 0; } diff --git a/libcfs/libcfs/linux/linux-tcpip.c b/libcfs/libcfs/linux/linux-tcpip.c index dd609c0..de1a63f 100644 --- a/libcfs/libcfs/linux/linux-tcpip.c +++ b/libcfs/libcfs/linux/linux-tcpip.c @@ -234,8 +234,6 @@ libcfs_ipif_enumerate (char ***namesp) rc = -ENOMEM; goto out1; } - /* NULL out all names[i] */ - memset (names, 0, nfound * sizeof(*names)); for (i = 0; i < nfound; i++) { diff --git a/lnet/klnds/o2iblnd/o2iblnd.c b/lnet/klnds/o2iblnd/o2iblnd.c index c0b4408..18ad6a6 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.c +++ b/lnet/klnds/o2iblnd/o2iblnd.c @@ -340,8 +340,6 @@ kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid) return -ENOMEM; } - memset(peer, 0, sizeof(*peer)); /* zero flags etc */ - peer->ibp_ni = ni; peer->ibp_nid = nid; peer->ibp_error = 0; diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 58e0126..1a2294f 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -475,7 +475,6 @@ lnet_freelist_init(lnet_freelist_t *fl, int n, int size) fl->fl_objsize = size; do { - memset(space, 0, size); list_add((struct list_head *)space, &fl->fl_list); space += size; } while (--n != 0); diff --git a/lnet/lnet/router.c b/lnet/lnet/router.c index f4827ad..e041a37 100644 --- a/lnet/lnet/router.c +++ b/lnet/lnet/router.c @@ -860,7 +860,6 @@ lnet_create_rc_data_locked(lnet_peer_t *gateway) if (pi == NULL) goto out; - memset(pi, 0, LNET_PINGINFO_SIZE); for (i = 0; i < LNET_MAX_RTR_NIS; i++) { pi->pi_ni[i].ns_nid = LNET_NID_ANY; pi->pi_ni[i].ns_status = LNET_NI_STATUS_INVALID; -- 1.8.3.1