[ofa-general] [PATCH 4 of 5] libnes: zero context struct at allocation time (prep for additional context ops)
Jack Morgenstein
jackm at dev.mellanox.co.il
Mon Dec 17 00:19:36 PST 2007
The ibv_context structure will be getting additional ops,
to be added at the end of the structure (and not as part of
the existing ibv_context_ops structure).
Reason: ibv_context_ops is declared directly as a member of ibv_context,
and not as a pointer. Binaries compiled with previous libibverbs versions
will not be backwards compatible if we add new operations to ibv_context_ops,
since fields following the ops structure will move.
To enable adding new operations at the end of the existing ibv_context struct,
all driver libraries MUST zero their context structure at allocation time, so
that new ops will be NULL by default.
Signed-off-by: Jack Morgenstein <jackm at dev.mellanox.co.il>
diff --git a/src/nes_umain.c b/src/nes_umain.c
index c4d0642..ff920ab 100644
--- a/src/nes_umain.c
+++ b/src/nes_umain.c
@@ -41,6 +41,7 @@
#include <errno.h>
#include <sys/mman.h>
#include <pthread.h>
+#include <string.h>
#include "nes_umain.h"
#include "nes-abi.h"
@@ -122,6 +123,7 @@ static struct ibv_context *nes_ualloc_context(struct ibv_device *ibdev, int cmd_
if (!nesvctx)
return NULL;
+ memset(nesvctx, 0, sizeof *nesvctx);
nesvctx->ibv_ctx.cmd_fd = cmd_fd;
if (ibv_cmd_get_context(&nesvctx->ibv_ctx, &cmd, sizeof cmd,
More information about the general
mailing list