Here are two warnings:

  schedwrk.c:52: warning: cast from pointer to integer of different size
  schedwrk.c:110: warning: cast to pointer from integer of different size

Here's how to avoid them.
These days, the only safe way is via a union.
The two accessor functions are just so that the code
itself isn't polluted with ugly union uses.

>From 780a5700934fec90c76b672312b1d91e7521f752 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Mon, 20 Apr 2009 12:26:43 +0200
Subject: [PATCH] schedwrk.c: avoid two int-pointer cast conversion warnings

* exec/schedwrk.c (void2handle, handle2void): New functions.
(schedwrk_do): Use void2handle rather than an unportable cast.
(schedwrk_create): Use handle2void rather than an unportable cast.
---
 exec/schedwrk.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/exec/schedwrk.c b/exec/schedwrk.c
index 299e4b1..5f07387 100644
--- a/exec/schedwrk.c
+++ b/exec/schedwrk.c
@@ -47,9 +47,18 @@ struct schedwrk_instance {
        void *callback_handle;
 };

+union u {
+  hdb_handle_t h;
+  const void *v;
+};
+static hdb_handle_t
+void2handle (const void *v) { union u u; u.v = v; return u.h; }
+static const void *
+handle2void (hdb_handle_t h) { union u u; u.h = h; return u.v; }
+
 static int schedwrk_do (enum totem_callback_token_type type, const void 
*context)
 {
-       hdb_handle_t handle = (hdb_handle_t)(unsigned int)context;
+       hdb_handle_t handle = void2handle (context);
        struct schedwrk_instance *instance;
        int res;

@@ -74,7 +83,7 @@ static int schedwrk_do (enum totem_callback_token_type type, 
const void *context
 error_exit:
        return (-1);
 }
-       
+
 void schedwrk_init (
        void (*serialize_lock_fn) (void),
        void (*serialize_unlock_fn) (void))
@@ -107,7 +116,7 @@ int schedwrk_create (
                TOTEM_CALLBACK_TOKEN_SENT,
                1,
                schedwrk_do,
-               (void *)(unsigned int)*handle);
+               handle2void (*handle));

        instance->schedwrk_fn = schedwrk_fn;
        instance->context = context;
-- 
1.6.3.rc0.230.g3edd6

_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to