ruby-changes:67959
From: Nobuyoshi <ko1@a...>
Date: Mon, 13 Sep 2021 00:51:23 +0900 (JST)
Subject: [ruby-changes:67959] 6920f3dc96 (master): [ruby/openssl] Suppress cast-function-type warnings
https://git.ruby-lang.org/ruby.git/commit/?id=6920f3dc96 From 6920f3dc964052112795dc9c5c4f9650807726c8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 12 Sep 2021 16:27:01 +0900 Subject: [ruby/openssl] Suppress cast-function-type warnings https://github.com/ruby/openssl/commit/0f91e2a6ee --- ext/openssl/ossl.c | 4 ++-- ext/openssl/ossl_asn1.c | 18 +++++++++++++++--- ext/openssl/ossl_cipher.c | 8 ++++---- ext/openssl/ossl_pkcs12.c | 24 +++++++++++++++++++++--- ext/openssl/ossl_pkey.c | 5 +++-- ext/openssl/ossl_ssl.c | 13 +++++++------ ext/openssl/ossl_ts.c | 24 +++++++++++++++++++++--- ext/openssl/ossl_x509store.c | 13 ++++++++++--- 8 files changed, 83 insertions(+), 26 deletions(-) diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index f214bcb..c7a755c 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -21,7 +21,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl.c#L21 * 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) \ https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl.c#L43 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 b4b2853..a61d3ee 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -69,6 +69,12 @@ asn1time_to_time(const ASN1_TIME *time) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_asn1.c#L69 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_asn1.c#L142 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_asn1.c#L337 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_asn1.c#L377 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_asn1.c#L439 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 28f5c1b..d9c7891 100644 --- a/ext/openssl/ossl_cipher.c +++ b/ext/openssl/ossl_cipher.c @@ -149,11 +149,11 @@ ossl_cipher_copy(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_cipher.c#L149 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_cipher.c#L169 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 4566334..fb947df 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkcs12.c#L149 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkcs12.c#L204 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 203ab78..95a2ea1 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 = { https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkey.c#L35 }; 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkey.c#L70 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 8f36527..4f24a83 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -239,22 +239,23 @@ struct tmp_dh_callback_args { https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L239 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L275 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 dbd7374..e2fd0fe 100644 --- a/ext/openssl/ossl_ts.c +++ b/ext/openssl/ossl_ts.c @@ -146,6 +146,12 @@ obj_to_asn1obj(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ts.c#L146 } 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ts.c#L1084 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ts.c#L1164 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ts.c#L1206 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_digestbyna (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/