summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-09-12 16:27:01 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-09-12 22:49:05 +0900
commit6920f3dc964052112795dc9c5c4f9650807726c8 (patch)
tree4220f817a1d050f60af7e183a893a259dc79d69e
parent598d66f6b2d1ab34dcd6db3bed70c59836a6206a (diff)
[ruby/openssl] Suppress cast-function-type warnings
https://github.com/ruby/openssl/commit/0f91e2a6ee
-rw-r--r--ext/openssl/ossl.c4
-rw-r--r--ext/openssl/ossl_asn1.c18
-rw-r--r--ext/openssl/ossl_cipher.c8
-rw-r--r--ext/openssl/ossl_pkcs12.c24
-rw-r--r--ext/openssl/ossl_pkey.c5
-rw-r--r--ext/openssl/ossl_ssl.c13
-rw-r--r--ext/openssl/ossl_ts.c24
-rw-r--r--ext/openssl/ossl_x509store.c13
8 files changed, 83 insertions, 26 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index f214bcb522..c7a755ceda 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -21,7 +21,7 @@
* Data Conversion
*/
#define OSSL_IMPL_ARY2SK(name, type, expected_class, dup) \
-STACK_OF(type) * \
+VALUE \
ossl_##name##_ary2sk0(VALUE ary) \
{ \
STACK_OF(type) *sk; \
@@ -43,7 +43,7 @@ ossl_##name##_ary2sk0(VALUE ary) \
x = dup(val); /* NEED TO DUP */ \
sk_##type##_push(sk, x); \
} \
- return sk; \
+ return (VALUE)sk; \
} \
\
STACK_OF(type) * \
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index b4b285323b..a61d3eefb1 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -69,6 +69,12 @@ asn1time_to_time(const ASN1_TIME *time)
return rb_funcall2(rb_cTime, rb_intern("utc"), 6, argv);
}
+static VALUE
+asn1time_to_time_i(VALUE arg)
+{
+ return asn1time_to_time((ASN1_TIME *)arg);
+}
+
void
ossl_time_split(VALUE time, time_t *sec, int *days)
{
@@ -136,6 +142,12 @@ num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
return ai;
}
+static VALUE
+asn1integer_to_num_i(VALUE arg)
+{
+ return asn1integer_to_num((ASN1_INTEGER *)arg);
+}
+
/********/
/*
* ASN1 module
@@ -325,7 +337,7 @@ decode_int(unsigned char* der, long length)
p = der;
if(!(ai = d2i_ASN1_INTEGER(NULL, &p, length)))
ossl_raise(eASN1Error, NULL);
- ret = rb_protect((VALUE (*)(VALUE))asn1integer_to_num,
+ ret = rb_protect(asn1integer_to_num_i,
(VALUE)ai, &status);
ASN1_INTEGER_free(ai);
if(status) rb_jump_tag(status);
@@ -365,7 +377,7 @@ decode_enum(unsigned char* der, long length)
p = der;
if(!(ai = d2i_ASN1_ENUMERATED(NULL, &p, length)))
ossl_raise(eASN1Error, NULL);
- ret = rb_protect((VALUE (*)(VALUE))asn1integer_to_num,
+ ret = rb_protect(asn1integer_to_num_i,
(VALUE)ai, &status);
ASN1_ENUMERATED_free(ai);
if(status) rb_jump_tag(status);
@@ -427,7 +439,7 @@ decode_time(unsigned char* der, long length)
p = der;
if(!(time = d2i_ASN1_TIME(NULL, &p, length)))
ossl_raise(eASN1Error, NULL);
- ret = rb_protect((VALUE (*)(VALUE))asn1time_to_time,
+ ret = rb_protect(asn1time_to_time_i,
(VALUE)time, &status);
ASN1_TIME_free(time);
if(status) rb_jump_tag(status);
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
index 28f5c1b5ef..d9c7891433 100644
--- a/ext/openssl/ossl_cipher.c
+++ b/ext/openssl/ossl_cipher.c
@@ -149,11 +149,11 @@ ossl_cipher_copy(VALUE self, VALUE other)
return self;
}
-static void*
-add_cipher_name_to_ary(const OBJ_NAME *name, VALUE ary)
+static void
+add_cipher_name_to_ary(const OBJ_NAME *name, void *arg)
{
+ VALUE ary = (VALUE)arg;
rb_ary_push(ary, rb_str_new2(name->name));
- return NULL;
}
/*
@@ -169,7 +169,7 @@ ossl_s_ciphers(VALUE self)
ary = rb_ary_new();
OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH,
- (void(*)(const OBJ_NAME*,void*))add_cipher_name_to_ary,
+ add_cipher_name_to_ary,
(void*)ary);
return ary;
diff --git a/ext/openssl/ossl_pkcs12.c b/ext/openssl/ossl_pkcs12.c
index 4566334481..fb947df1d0 100644
--- a/ext/openssl/ossl_pkcs12.c
+++ b/ext/openssl/ossl_pkcs12.c
@@ -149,6 +149,24 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
return obj;
}
+static VALUE
+ossl_pkey_new_i(VALUE arg)
+{
+ return ossl_pkey_new((EVP_PKEY *)arg);
+}
+
+static VALUE
+ossl_x509_new_i(VALUE arg)
+{
+ return ossl_x509_new((X509 *)arg);
+}
+
+static VALUE
+ossl_x509_sk2ary_i(VALUE arg)
+{
+ return ossl_x509_sk2ary((STACK_OF(X509) *)arg);
+}
+
/*
* call-seq:
* PKCS12.new -> pkcs12
@@ -186,15 +204,15 @@ ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self)
ossl_raise(ePKCS12Error, "PKCS12_parse");
ERR_pop_to_mark();
if (key) {
- pkey = rb_protect((VALUE (*)(VALUE))ossl_pkey_new, (VALUE)key, &st);
+ pkey = rb_protect(ossl_pkey_new_i, (VALUE)key, &st);
if (st) goto err;
}
if (x509) {
- cert = rb_protect((VALUE (*)(VALUE))ossl_x509_new, (VALUE)x509, &st);
+ cert = rb_protect(ossl_x509_new_i, (VALUE)x509, &st);
if (st) goto err;
}
if (x509s) {
- ca = rb_protect((VALUE (*)(VALUE))ossl_x509_sk2ary, (VALUE)x509s, &st);
+ ca = rb_protect(ossl_x509_sk2ary_i, (VALUE)x509s, &st);
if (st) goto err;
}
diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c
index 203ab789ca..95a2ea1ed9 100644
--- a/ext/openssl/ossl_pkey.c
+++ b/ext/openssl/ossl_pkey.c
@@ -35,8 +35,9 @@ const rb_data_type_t ossl_evp_pkey_type = {
};
static VALUE
-pkey_new0(EVP_PKEY *pkey)
+pkey_new0(VALUE arg)
{
+ EVP_PKEY *pkey = (EVP_PKEY *)arg;
VALUE klass, obj;
int type;
@@ -69,7 +70,7 @@ ossl_pkey_new(EVP_PKEY *pkey)
VALUE obj;
int status;
- obj = rb_protect((VALUE (*)(VALUE))pkey_new0, (VALUE)pkey, &status);
+ obj = rb_protect(pkey_new0, (VALUE)pkey, &status);
if (status) {
EVP_PKEY_free(pkey);
rb_jump_tag(status);
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 8f365278f9..4f24a8339d 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -239,22 +239,23 @@ struct tmp_dh_callback_args {
int keylength;
};
-static EVP_PKEY *
-ossl_call_tmp_dh_callback(struct tmp_dh_callback_args *args)
+static VALUE
+ossl_call_tmp_dh_callback(VALUE arg)
{
+ struct tmp_dh_callback_args *args = (struct tmp_dh_callback_args *)arg;
VALUE cb, dh;
EVP_PKEY *pkey;
cb = rb_funcall(args->ssl_obj, args->id, 0);
if (NIL_P(cb))
- return NULL;
+ return (VALUE)NULL;
dh = rb_funcall(cb, id_call, 3, args->ssl_obj, INT2NUM(args->is_export),
INT2NUM(args->keylength));
pkey = GetPKeyPtr(dh);
if (EVP_PKEY_base_id(pkey) != args->type)
- return NULL;
+ return (VALUE)NULL;
- return pkey;
+ return (VALUE)pkey;
}
#endif
@@ -274,7 +275,7 @@ ossl_tmp_dh_callback(SSL *ssl, int is_export, int keylength)
args.keylength = keylength;
args.type = EVP_PKEY_DH;
- pkey = (EVP_PKEY *)rb_protect((VALUE (*)(VALUE))ossl_call_tmp_dh_callback,
+ pkey = (EVP_PKEY *)rb_protect(ossl_call_tmp_dh_callback,
(VALUE)&args, &state);
if (state) {
rb_ivar_set(rb_ssl, ID_callback_state, INT2NUM(state));
diff --git a/ext/openssl/ossl_ts.c b/ext/openssl/ossl_ts.c
index dbd73748a9..e2fd0fe06e 100644
--- a/ext/openssl/ossl_ts.c
+++ b/ext/openssl/ossl_ts.c
@@ -146,6 +146,12 @@ obj_to_asn1obj(VALUE obj)
}
static VALUE
+obj_to_asn1obj_i(VALUE obj)
+{
+ return (VALUE)obj_to_asn1obj(obj);
+}
+
+static VALUE
get_asn1obj(ASN1_OBJECT *obj)
{
BIO *out;
@@ -1078,6 +1084,18 @@ ossl_tsfac_time_cb(struct TS_resp_ctx *ctx, void *data, long *sec, long *usec)
return 1;
}
+static VALUE
+ossl_evp_get_digestbyname_i(VALUE arg)
+{
+ return (VALUE)ossl_evp_get_digestbyname(arg);
+}
+
+static VALUE
+ossl_obj2bio_i(VALUE arg)
+{
+ return (VALUE)ossl_obj2bio((VALUE *)arg);
+}
+
/*
* Creates a Response with the help of an OpenSSL::PKey, an
* OpenSSL::X509::Certificate and a Request.
@@ -1146,7 +1164,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
goto end;
}
if (!NIL_P(def_policy_id) && !TS_REQ_get_policy_id(req)) {
- def_policy_id_obj = (ASN1_OBJECT*)rb_protect((VALUE (*)(VALUE))obj_to_asn1obj, (VALUE)def_policy_id, &status);
+ def_policy_id_obj = (ASN1_OBJECT*)rb_protect(obj_to_asn1obj_i, (VALUE)def_policy_id, &status);
if (status)
goto end;
}
@@ -1188,7 +1206,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
for (i = 0; i < RARRAY_LEN(allowed_digests); i++) {
rbmd = rb_ary_entry(allowed_digests, i);
- md = (const EVP_MD *)rb_protect((VALUE (*)(VALUE))ossl_evp_get_digestbyname, rbmd, &status);
+ md = (const EVP_MD *)rb_protect(ossl_evp_get_digestbyname_i, rbmd, &status);
if (status)
goto end;
TS_RESP_CTX_add_md(ctx, md);
@@ -1199,7 +1217,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
if (status)
goto end;
- req_bio = (BIO*)rb_protect((VALUE (*)(VALUE))ossl_obj2bio, (VALUE)&str, &status);
+ req_bio = (BIO*)rb_protect(ossl_obj2bio_i, (VALUE)&str, &status);
if (status)
goto end;
diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c
index 5e0ab8d850..f494dbc908 100644
--- a/ext/openssl/ossl_x509store.c
+++ b/ext/openssl/ossl_x509store.c
@@ -52,8 +52,15 @@ struct ossl_verify_cb_args {
};
static VALUE
-call_verify_cb_proc(struct ossl_verify_cb_args *args)
+ossl_x509stctx_new_i(VALUE arg)
{
+ return ossl_x509stctx_new((X509_STORE_CTX *)arg);
+}
+
+static VALUE
+call_verify_cb_proc(VALUE arg)
+{
+ struct ossl_verify_cb_args *args = (struct ossl_verify_cb_args *)arg;
return rb_funcall(args->proc, rb_intern("call"), 2,
args->preverify_ok, args->store_ctx);
}
@@ -69,7 +76,7 @@ ossl_verify_cb_call(VALUE proc, int ok, X509_STORE_CTX *ctx)
return ok;
ret = Qfalse;
- rctx = rb_protect((VALUE(*)(VALUE))ossl_x509stctx_new, (VALUE)ctx, &state);
+ rctx = rb_protect(ossl_x509stctx_new_i, (VALUE)ctx, &state);
if (state) {
rb_set_errinfo(Qnil);
rb_warn("StoreContext initialization failure");
@@ -78,7 +85,7 @@ ossl_verify_cb_call(VALUE proc, int ok, X509_STORE_CTX *ctx)
args.proc = proc;
args.preverify_ok = ok ? Qtrue : Qfalse;
args.store_ctx = rctx;
- ret = rb_protect((VALUE(*)(VALUE))call_verify_cb_proc, (VALUE)&args, &state);
+ ret = rb_protect(call_verify_cb_proc, (VALUE)&args, &state);
if (state) {
rb_set_errinfo(Qnil);
rb_warn("exception in verify_callback is ignored");