couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject couchdb-khash git commit: Fix "dereferencing type-punned pointer will break strict-aliasing" warn
Date Thu, 16 Jul 2015 16:28:52 GMT
Repository: couchdb-khash
Updated Branches:
  refs/heads/master f87d8bc73 -> f8a77ddb1


Fix "dereferencing type-punned pointer will break strict-aliasing" warn

COUCHDB-2588


Project: http://git-wip-us.apache.org/repos/asf/couchdb-khash/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-khash/commit/f8a77ddb
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-khash/tree/f8a77ddb
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-khash/diff/f8a77ddb

Branch: refs/heads/master
Commit: f8a77ddb146c7ae2c0278f4901a9c2172c18be6e
Parents: f87d8bc
Author: Alexander Shorin <kxepal@apache.org>
Authored: Thu Jul 16 00:09:08 2015 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Thu Jul 16 00:09:08 2015 +0300

----------------------------------------------------------------------
 c_src/khash.c | 58 ++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 41 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-khash/blob/f8a77ddb/c_src/khash.c
----------------------------------------------------------------------
diff --git a/c_src/khash.c b/c_src/khash.c
index d206f5e..a2364b0 100644
--- a/c_src/khash.c
+++ b/c_src/khash.c
@@ -217,7 +217,8 @@ khash_to_list(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
 {
     khash_priv* priv = (khash_priv*) enif_priv_data(env);
     ERL_NIF_TERM ret = enif_make_list(env, 0);
-    khash_t* khash;
+    khash_t* khash = NULL;
+    void* res = NULL;
     hscan_t scan;
     hnode_t* entry;
     khnode_t* node;
@@ -229,10 +230,12 @@ khash_to_list(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
         return enif_make_badarg(env);
     }
 
-    if(!enif_get_resource(env, argv[0], priv->res_hash, (void**) &khash)) {
+    if(!enif_get_resource(env, argv[0], priv->res_hash, &res)) {
         return enif_make_badarg(env);
     }
 
+    khash = (khash_t*) res;
+
     if(!check_pid(env, khash)) {
         return enif_make_badarg(env);
     }
@@ -255,16 +258,19 @@ static ERL_NIF_TERM
 khash_clear(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
 {
     khash_priv* priv = enif_priv_data(env);
-    khash_t* khash;
+    khash_t* khash = NULL;
+    void* res = NULL;
 
     if(argc != 1) {
         return enif_make_badarg(env);
     }
 
-    if(!enif_get_resource(env, argv[0], priv->res_hash, (void**) &khash)) {
+    if(!enif_get_resource(env, argv[0], priv->res_hash, &res)) {
         return enif_make_badarg(env);
     }
 
+    khash = (khash_t*) res;
+
     if(!check_pid(env, khash)) {
         return enif_make_badarg(env);
     }
@@ -291,7 +297,8 @@ static ERL_NIF_TERM
 khash_lookup(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
 {
     khash_priv* priv = enif_priv_data(env);
-    khash_t* khash;
+    khash_t* khash = NULL;
+    void* res = NULL;
     hnode_t* entry;
     khnode_t* node;
     ERL_NIF_TERM ret;
@@ -300,10 +307,12 @@ khash_lookup(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
         return enif_make_badarg(env);
     }
 
-    if(!enif_get_resource(env, argv[0], priv->res_hash, (void**) &khash)) {
+    if(!enif_get_resource(env, argv[0], priv->res_hash, &res)) {
         return enif_make_badarg(env);
     }
 
+    khash = (khash_t*) res;
+
     if(!check_pid(env, khash)) {
         return enif_make_badarg(env);
     }
@@ -325,7 +334,8 @@ static ERL_NIF_TERM
 khash_get(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
 {
     khash_priv* priv = enif_priv_data(env);
-    khash_t* khash;
+    khash_t* khash = NULL;
+    void* res = NULL;
     hnode_t* entry;
     khnode_t* node;
     ERL_NIF_TERM ret;
@@ -334,10 +344,12 @@ khash_get(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
         return enif_make_badarg(env);
     }
 
-    if(!enif_get_resource(env, argv[0], priv->res_hash, (void**) &khash)) {
+    if(!enif_get_resource(env, argv[0], priv->res_hash, &res)) {
         return enif_make_badarg(env);
     }
 
+    khash = (khash_t*) res;
+
     if(!check_pid(env, khash)) {
         return enif_make_badarg(env);
     }
@@ -358,7 +370,8 @@ static ERL_NIF_TERM
 khash_put(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
 {
     khash_priv* priv = enif_priv_data(env);
-    khash_t* khash;
+    khash_t* khash = NULL;
+    void* res = NULL;
     hnode_t* entry;
     khnode_t* node;
 
@@ -366,10 +379,12 @@ khash_put(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
         return enif_make_badarg(env);
     }
 
-    if(!enif_get_resource(env, argv[0], priv->res_hash, (void**) &khash)) {
+    if(!enif_get_resource(env, argv[0], priv->res_hash, &res)) {
         return enif_make_badarg(env);
     }
 
+    khash = (khash_t*) res;
+
     if(!check_pid(env, khash)) {
         return enif_make_badarg(env);
     }
@@ -398,7 +413,8 @@ static ERL_NIF_TERM
 khash_del(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
 {
     khash_priv* priv = enif_priv_data(env);
-    khash_t* khash;
+    khash_t* khash = NULL;
+    void* res = NULL;
     hnode_t* entry;
     ERL_NIF_TERM ret;
 
@@ -406,10 +422,12 @@ khash_del(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
         return enif_make_badarg(env);
     }
 
-    if(!enif_get_resource(env, argv[0], priv->res_hash, (void**) &khash)) {
+    if(!enif_get_resource(env, argv[0], priv->res_hash, &res)) {
         return enif_make_badarg(env);
     }
 
+    khash = (khash_t*) res;
+
     if(!check_pid(env, khash)) {
         return enif_make_badarg(env);
     }
@@ -438,7 +456,7 @@ khash_size(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
         return enif_make_badarg(env);
     }
 
-    if(!enif_get_resource(env, argv[0], priv->res_hash, (void**) &khash)) {
+    if(!enif_get_resource(env, argv[0], priv->res_hash, (void*) &khash)) {
         return enif_make_badarg(env);
     }
 
@@ -454,7 +472,8 @@ static ERL_NIF_TERM
 khash_iter(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
 {
     khash_priv* priv = enif_priv_data(env);
-    khash_t* khash;
+    khash_t* khash = NULL;
+    void* res = NULL;
     khash_iter_t* iter;
     ERL_NIF_TERM ret;
 
@@ -462,10 +481,12 @@ khash_iter(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
         return enif_make_badarg(env);
     }
 
-    if(!enif_get_resource(env, argv[0], priv->res_hash, (void**) &khash)) {
+    if(!enif_get_resource(env, argv[0], priv->res_hash, &res)) {
         return enif_make_badarg(env);
     }
 
+    khash = (khash_t*) res;
+
     if(!check_pid(env, khash)) {
         return enif_make_badarg(env);
     }
@@ -501,7 +522,8 @@ static ERL_NIF_TERM
 khash_iter_next(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
 {
     khash_priv* priv = enif_priv_data(env);
-    khash_iter_t* iter;
+    khash_iter_t* iter = NULL;
+    void* res = NULL;
     hnode_t* entry;
     khnode_t* node;
     ERL_NIF_TERM key;
@@ -511,10 +533,12 @@ khash_iter_next(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
         return enif_make_badarg(env);
     }
 
-    if(!enif_get_resource(env, argv[0], priv->res_iter, (void**) &iter)) {
+    if(!enif_get_resource(env, argv[0], priv->res_iter, &res)) {
         return enif_make_badarg(env);
     }
 
+    iter = (khash_iter_t*) res;
+
     if(!check_pid(env, iter->khash)) {
         return enif_make_badarg(env);
     }


Mime
View raw message