* [PATCH 11/37] librdmacm: add zalloc call
@ 2010-04-07 17:12 Sean Hefty
[not found] ` <53A8AB949BCE4311B58A4881EC549E90-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Sean Hefty @ 2010-04-07 17:12 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
src/cma.c | 6 ++----
src/cma.h | 10 ++++++++++
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/cma.c b/src/cma.c
index a85448b..4025aeb 100644
--- a/src/cma.c
+++ b/src/cma.c
@@ -342,11 +342,10 @@ static struct cma_id_private *ucma_alloc_id(struct rdma_event_channel *channel,
{
struct cma_id_private *id_priv;
- id_priv = malloc(sizeof *id_priv);
+ id_priv = zalloc(sizeof *id_priv);
if (!id_priv)
return NULL;
- memset(id_priv, 0, sizeof *id_priv);
id_priv->id.context = context;
id_priv->id.ps = ps;
id_priv->id.channel = channel;
@@ -1228,11 +1227,10 @@ static int rdma_join_multicast2(struct rdma_cm_id *id, struct sockaddr *addr,
int ret, size;
id_priv = container_of(id, struct cma_id_private, id);
- mc = malloc(sizeof *mc);
+ mc = zalloc(sizeof *mc);
if (!mc)
return ERR(ENOMEM);
- memset(mc, 0, sizeof *mc);
mc->context = context;
mc->id_priv = id_priv;
memcpy(&mc->addr, addr, addrlen);
diff --git a/src/cma.h b/src/cma.h
index 1c0ab8b..fcfb1f7 100644
--- a/src/cma.h
+++ b/src/cma.h
@@ -42,6 +42,7 @@
#include <errno.h>
#include <endian.h>
#include <byteswap.h>
+#include <string.h>
#ifdef INCLUDE_VALGRIND
# include <valgrind/memcheck.h>
@@ -70,5 +71,14 @@ static inline int ERR(int err)
return -1;
}
+static inline void *zalloc(size_t size)
+{
+ void *buf;
+
+ if ((buf = malloc(size)))
+ memset(buf, 0, size);
+ return buf;
+}
+
#endif /* CMA_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 11/37] librdmacm: add zalloc call
[not found] ` <53A8AB949BCE4311B58A4881EC549E90-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2010-04-07 19:19 ` Jason Gunthorpe
[not found] ` <20100407191938.GF15629-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Jason Gunthorpe @ 2010-04-07 19:19 UTC (permalink / raw)
To: Sean Hefty; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
On Wed, Apr 07, 2010 at 10:12:44AM -0700, Sean Hefty wrote:
> Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>
> src/cma.c | 6 ++----
> src/cma.h | 10 ++++++++++
> 2 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/src/cma.c b/src/cma.c
> index a85448b..4025aeb 100644
> +++ b/src/cma.c
> @@ -342,11 +342,10 @@ static struct cma_id_private *ucma_alloc_id(struct rdma_event_channel *channel,
> {
> struct cma_id_private *id_priv;
>
> - id_priv = malloc(sizeof *id_priv);
> + id_priv = zalloc(sizeof *id_priv);
> if (!id_priv)
> return NULL;
Maybe use calloc(,1 sizeof(x)); instead?
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH 11/37] librdmacm: add zalloc call
[not found] ` <20100407191938.GF15629-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2010-04-08 16:14 ` Sean Hefty
0 siblings, 0 replies; 3+ messages in thread
From: Sean Hefty @ 2010-04-08 16:14 UTC (permalink / raw)
To: 'Jason Gunthorpe'; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
>Maybe use calloc(,1 sizeof(x)); instead?
yes - I'll update the patches, but won't repost for this change.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-08 16:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-07 17:12 [PATCH 11/37] librdmacm: add zalloc call Sean Hefty
[not found] ` <53A8AB949BCE4311B58A4881EC549E90-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-04-07 19:19 ` Jason Gunthorpe
[not found] ` <20100407191938.GF15629-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-04-08 16:14 ` Sean Hefty
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.