[ofa-general] Re: [PATCH 5 of 5] libipathverbs: zero context struct at allocation time (prep for additional context ops)

Ralph Campbell ralph.campbell at qlogic.com
Mon Dec 17 10:48:02 PST 2007


Thanks, applied to ~ralphc/libipathverbs/.git ofed_1_3 branch.

On Mon, 2007-12-17 at 10:19 +0200, Jack Morgenstein wrote:
> 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/ipathverbs.c b/src/ipathverbs.c
> index eb16fb0..55d8dcf 100644
> --- a/src/ipathverbs.c
> +++ b/src/ipathverbs.c
> @@ -42,6 +42,7 @@
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <unistd.h>
> +#include <string.h>
>  
>  #include "ipathverbs.h"
>  #include "ipath-abi.h"
> @@ -140,6 +141,7 @@ static struct ibv_context *ipath_alloc_context(struct ibv_device *ibdev,
>  	context = malloc(sizeof *context);
>  	if (!context)
>  		return NULL;
> +	memset(context, 0, sizeof *context);
>  	context->ibv_ctx.cmd_fd = cmd_fd;
>  	if (ibv_cmd_get_context(&context->ibv_ctx, &cmd,
>  				sizeof cmd, &resp, sizeof resp))




More information about the general mailing list