Commits

Benjamin Black committed cdd0553

Fix types for atom generation (maybe)

Comments (0)

Files changed (1)

     {"final", 1, skein_final},
     {"hash", 2, skein_hash}
 };
-
+	
+static char *hash_return_strings[] = {"success", "fail", "bad hashlen"};
 
 ERL_NIF_TERM skein_init(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
 {   
     hashState *state = enif_alloc_resource(env, skein_hashstate, sizeof(hashState));
     HashReturn r = Init(state, bits);
     if (r == SUCCESS) {
-        ERL_NIF_TERM result = enif_make_resource(env, state);
+        enif_make_resource(env, state);
         enif_release_resource(env, state);
         return enif_make_tuple2(env, enif_make_atom(env, "ok"), state);
     } else {
         enif_release_resource(env, state);
-        return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, r));
+        return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, hash_return_strings[r]));
     }
 }
 
         return enif_make_tuple2(env, enif_make_atom(env, "ok"), state);
     } else {
         enif_release_resource(env, state);
-        return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, r));
+        return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, hash_return_strings[r]));
     }
 }
 
     BitSequence *hashval = enif_alloc_resource(env, skein_hashval, sizeof(state->statebits / 8));
     HashReturn r = Final(state, hashval);
     if (r == SUCCESS) {
-        ERL_NIF_TERM result = enif_make_resource(env, hashval);
+        enif_make_resource(env, hashval);
         enif_release_resource(env, hashval);
         return enif_make_tuple2(env, enif_make_atom(env, "ok"), hashval);
     } else {
         enif_release_resource(env, hashval);
-        return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, r));
+        return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, hash_return_strings[r]));
     }
 }
 
     BitSequence *hashval = enif_alloc_resource(env, skein_hashval, sizeof(bits / 8));
     HashReturn r = Hash(bits, (BitSequence *)(bin.data), bin.size * 8, hashval);
     if (r == SUCCESS) {
-        ERL_NIF_TERM result = enif_make_resource(env, hashval);
+        enif_make_resource(env, hashval);
         enif_release_resource(env, hashval);
         return enif_make_tuple2(env, enif_make_atom(env, "ok"), hashval);
     } else {
         enif_release_resource(env, hashval);
-        return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, r));
+        return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, hash_return_strings[r]));
     }   
 }