Просмотр исходного кода

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.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2098 fd59a12c-fef9-0310-b244-a6a79926bd2f
Jim Meyering 17 лет назад
Родитель
Сommit
7c312c6f62
1 измененных файлов с 12 добавлено и 3 удалено
  1. 12 3
      exec/schedwrk.c

+ 12 - 3
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;