[Devel] Re: [PATCH/RFC] objhash.c: fix (?) invalid casts

Serge E. Hallyn serue at us.ibm.com
Thu Jan 15 14:02:27 PST 2009


Quoting Nathan Lynch (ntl at pobox.com):
> When building 64-bit powerpc:
> 
> checkpoint/objhash.c: In function 'cr_obj_find_by_objref':
> checkpoint/objhash.c:121: warning: cast to pointer from integer of different size
> checkpoint/objhash.c: In function 'cr_obj_new':
> checkpoint/objhash.c:158: warning: cast to pointer from integer of different size
> 
> Is this the right fix or is struct cr_objref->objref the wrong type?

Yeah, Dave suggested on irc changing objref to an unsigned long,
and in fact switching to hash_long().  Oren, what do you think?

Meanwhile, obviously, when I tested the s390 c/r patch it was on top of
these two patches.  Worked beautifuly, thanks.

-serge

> ---
>  checkpoint/objhash.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> This is on top of v12 of the C/R patches.
> 
> diff --git a/checkpoint/objhash.c b/checkpoint/objhash.c
> index 13d3e5d..cb08d3c 100644
> --- a/checkpoint/objhash.c
> +++ b/checkpoint/objhash.c
> @@ -118,7 +118,8 @@ static struct cr_objref *cr_obj_find_by_objref(struct cr_ctx *ctx, int objref)
>  	struct hlist_node *n;
>  	struct cr_objref *obj;
> 
> -	h = &ctx->objhash->head[hash_ptr((void *) objref, CR_OBJHASH_NBITS)];
> +	h = &ctx->objhash->head[hash_ptr((void *)(unsigned long)objref,
> +					 CR_OBJHASH_NBITS)];
>  	hlist_for_each_entry(obj, n, h, hash)
>  		if (obj->objref == objref)
>  			return obj;
> @@ -155,7 +156,7 @@ static struct cr_objref *cr_obj_new(struct cr_ctx *ctx, void *ptr, int objref,
>  	if (objref) {
>  		/* use @objref to index (restart) */
>  		obj->objref = objref;
> -		i = hash_ptr((void *) objref, CR_OBJHASH_NBITS);
> +		i = hash_ptr((void *)(unsigned long)objref, CR_OBJHASH_NBITS);
>  	} else {
>  		/* use @ptr to index, assign objref (checkpoint) */
>  		obj->objref = ctx->objhash->next_free_objref++;;
> -- 
> 1.5.5
> 
> _______________________________________________
> Containers mailing list
> Containers at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list