* [PATCH/RFC] objhash.c: fix (?) invalid casts
@ 2009-01-15 19:40 Nathan Lynch
2009-01-15 22:02 ` Serge E. Hallyn
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Lynch @ 2009-01-15 19:40 UTC (permalink / raw)
To: containers-qjLDD68F18O7TbgM5vRIOg; +Cc: Dave Hansen
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?
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH/RFC] objhash.c: fix (?) invalid casts
2009-01-15 19:40 [PATCH/RFC] objhash.c: fix (?) invalid casts Nathan Lynch
@ 2009-01-15 22:02 ` Serge E. Hallyn
0 siblings, 0 replies; 2+ messages in thread
From: Serge E. Hallyn @ 2009-01-15 22:02 UTC (permalink / raw)
To: Nathan Lynch, Oren Laadan; +Cc: containers-qjLDD68F18O7TbgM5vRIOg, Dave Hansen
Quoting Nathan Lynch (ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org):
> 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-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-01-15 22:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-15 19:40 [PATCH/RFC] objhash.c: fix (?) invalid casts Nathan Lynch
2009-01-15 22:02 ` Serge E. Hallyn
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.