Skip to content

Commit 5c85b43

Browse files
authored
Merge pull request #456 from ruby/compilation-warnings
Suppress compilation warnings
2 parents cf54f72 + 258e30b commit 5c85b43

9 files changed

+87
-26
lines changed

ext/openssl/ossl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Data Conversion
2222
*/
2323
#define OSSL_IMPL_ARY2SK(name, type, expected_class, dup) \
24-
STACK_OF(type) * \
24+
VALUE \
2525
ossl_##name##_ary2sk0(VALUE ary) \
2626
{ \
2727
STACK_OF(type) *sk; \
@@ -43,7 +43,7 @@ ossl_##name##_ary2sk0(VALUE ary) \
4343
x = dup(val); /* NEED TO DUP */ \
4444
sk_##type##_push(sk, x); \
4545
} \
46-
return sk; \
46+
return (VALUE)sk; \
4747
} \
4848
\
4949
STACK_OF(type) * \

ext/openssl/ossl_asn1.c

+15-3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ asn1time_to_time(const ASN1_TIME *time)
6969
return rb_funcall2(rb_cTime, rb_intern("utc"), 6, argv);
7070
}
7171

72+
static VALUE
73+
asn1time_to_time_i(VALUE arg)
74+
{
75+
return asn1time_to_time((ASN1_TIME *)arg);
76+
}
77+
7278
void
7379
ossl_time_split(VALUE time, time_t *sec, int *days)
7480
{
@@ -136,6 +142,12 @@ num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
136142
return ai;
137143
}
138144

145+
static VALUE
146+
asn1integer_to_num_i(VALUE arg)
147+
{
148+
return asn1integer_to_num((ASN1_INTEGER *)arg);
149+
}
150+
139151
/********/
140152
/*
141153
* ASN1 module
@@ -325,7 +337,7 @@ decode_int(unsigned char* der, long length)
325337
p = der;
326338
if(!(ai = d2i_ASN1_INTEGER(NULL, &p, length)))
327339
ossl_raise(eASN1Error, NULL);
328-
ret = rb_protect((VALUE (*)(VALUE))asn1integer_to_num,
340+
ret = rb_protect(asn1integer_to_num_i,
329341
(VALUE)ai, &status);
330342
ASN1_INTEGER_free(ai);
331343
if(status) rb_jump_tag(status);
@@ -365,7 +377,7 @@ decode_enum(unsigned char* der, long length)
365377
p = der;
366378
if(!(ai = d2i_ASN1_ENUMERATED(NULL, &p, length)))
367379
ossl_raise(eASN1Error, NULL);
368-
ret = rb_protect((VALUE (*)(VALUE))asn1integer_to_num,
380+
ret = rb_protect(asn1integer_to_num_i,
369381
(VALUE)ai, &status);
370382
ASN1_ENUMERATED_free(ai);
371383
if(status) rb_jump_tag(status);
@@ -427,7 +439,7 @@ decode_time(unsigned char* der, long length)
427439
p = der;
428440
if(!(time = d2i_ASN1_TIME(NULL, &p, length)))
429441
ossl_raise(eASN1Error, NULL);
430-
ret = rb_protect((VALUE (*)(VALUE))asn1time_to_time,
442+
ret = rb_protect(asn1time_to_time_i,
431443
(VALUE)time, &status);
432444
ASN1_TIME_free(time);
433445
if(status) rb_jump_tag(status);

ext/openssl/ossl_cipher.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ ossl_cipher_copy(VALUE self, VALUE other)
149149
return self;
150150
}
151151

152-
static void*
153-
add_cipher_name_to_ary(const OBJ_NAME *name, VALUE ary)
152+
static void
153+
add_cipher_name_to_ary(const OBJ_NAME *name, void *arg)
154154
{
155+
VALUE ary = (VALUE)arg;
155156
rb_ary_push(ary, rb_str_new2(name->name));
156-
return NULL;
157157
}
158158

159159
/*
@@ -169,7 +169,7 @@ ossl_s_ciphers(VALUE self)
169169

170170
ary = rb_ary_new();
171171
OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH,
172-
(void(*)(const OBJ_NAME*,void*))add_cipher_name_to_ary,
172+
add_cipher_name_to_ary,
173173
(void*)ary);
174174

175175
return ary;

ext/openssl/ossl_pkcs12.c

+21-3
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
149149
return obj;
150150
}
151151

152+
static VALUE
153+
ossl_pkey_new_i(VALUE arg)
154+
{
155+
return ossl_pkey_new((EVP_PKEY *)arg);
156+
}
157+
158+
static VALUE
159+
ossl_x509_new_i(VALUE arg)
160+
{
161+
return ossl_x509_new((X509 *)arg);
162+
}
163+
164+
static VALUE
165+
ossl_x509_sk2ary_i(VALUE arg)
166+
{
167+
return ossl_x509_sk2ary((STACK_OF(X509) *)arg);
168+
}
169+
152170
/*
153171
* call-seq:
154172
* PKCS12.new -> pkcs12
@@ -186,15 +204,15 @@ ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self)
186204
ossl_raise(ePKCS12Error, "PKCS12_parse");
187205
ERR_pop_to_mark();
188206
if (key) {
189-
pkey = rb_protect((VALUE (*)(VALUE))ossl_pkey_new, (VALUE)key, &st);
207+
pkey = rb_protect(ossl_pkey_new_i, (VALUE)key, &st);
190208
if (st) goto err;
191209
}
192210
if (x509) {
193-
cert = rb_protect((VALUE (*)(VALUE))ossl_x509_new, (VALUE)x509, &st);
211+
cert = rb_protect(ossl_x509_new_i, (VALUE)x509, &st);
194212
if (st) goto err;
195213
}
196214
if (x509s) {
197-
ca = rb_protect((VALUE (*)(VALUE))ossl_x509_sk2ary, (VALUE)x509s, &st);
215+
ca = rb_protect(ossl_x509_sk2ary_i, (VALUE)x509s, &st);
198216
if (st) goto err;
199217
}
200218

ext/openssl/ossl_pkey.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ const rb_data_type_t ossl_evp_pkey_type = {
3535
};
3636

3737
static VALUE
38-
pkey_new0(EVP_PKEY *pkey)
38+
pkey_new0(VALUE arg)
3939
{
40+
EVP_PKEY *pkey = (EVP_PKEY *)arg;
4041
VALUE klass, obj;
4142
int type;
4243

@@ -69,7 +70,7 @@ ossl_pkey_new(EVP_PKEY *pkey)
6970
VALUE obj;
7071
int status;
7172

72-
obj = rb_protect((VALUE (*)(VALUE))pkey_new0, (VALUE)pkey, &status);
73+
obj = rb_protect(pkey_new0, (VALUE)pkey, &status);
7374
if (status) {
7475
EVP_PKEY_free(pkey);
7576
rb_jump_tag(status);

ext/openssl/ossl_pkey_ec.c

+2
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ static VALUE ossl_ec_key_set_private_key(VALUE self, VALUE private_key)
288288
case 0:
289289
if (bn == NULL)
290290
break;
291+
/* fallthrough */
291292
default:
292293
ossl_raise(eECError, "EC_KEY_set_private_key");
293294
}
@@ -334,6 +335,7 @@ static VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key)
334335
case 0:
335336
if (point == NULL)
336337
break;
338+
/* fallthrough */
337339
default:
338340
ossl_raise(eECError, "EC_KEY_set_public_key");
339341
}

ext/openssl/ossl_ssl.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -239,22 +239,23 @@ struct tmp_dh_callback_args {
239239
int keylength;
240240
};
241241

242-
static EVP_PKEY *
243-
ossl_call_tmp_dh_callback(struct tmp_dh_callback_args *args)
242+
static VALUE
243+
ossl_call_tmp_dh_callback(VALUE arg)
244244
{
245+
struct tmp_dh_callback_args *args = (struct tmp_dh_callback_args *)arg;
245246
VALUE cb, dh;
246247
EVP_PKEY *pkey;
247248

248249
cb = rb_funcall(args->ssl_obj, args->id, 0);
249250
if (NIL_P(cb))
250-
return NULL;
251+
return (VALUE)NULL;
251252
dh = rb_funcall(cb, id_call, 3, args->ssl_obj, INT2NUM(args->is_export),
252253
INT2NUM(args->keylength));
253254
pkey = GetPKeyPtr(dh);
254255
if (EVP_PKEY_base_id(pkey) != args->type)
255-
return NULL;
256+
return (VALUE)NULL;
256257

257-
return pkey;
258+
return (VALUE)pkey;
258259
}
259260
#endif
260261

@@ -274,7 +275,7 @@ ossl_tmp_dh_callback(SSL *ssl, int is_export, int keylength)
274275
args.keylength = keylength;
275276
args.type = EVP_PKEY_DH;
276277

277-
pkey = (EVP_PKEY *)rb_protect((VALUE (*)(VALUE))ossl_call_tmp_dh_callback,
278+
pkey = (EVP_PKEY *)rb_protect(ossl_call_tmp_dh_callback,
278279
(VALUE)&args, &state);
279280
if (state) {
280281
rb_ivar_set(rb_ssl, ID_callback_state, INT2NUM(state));
@@ -1620,6 +1621,7 @@ ossl_start_ssl(VALUE self, int (*func)(), const char *funcname, VALUE opts)
16201621
err_msg, verify_msg);
16211622
}
16221623
#endif
1624+
/* fallthrough */
16231625
default:
16241626
ossl_raise(eSSLError, "%s returned=%d errno=%d peeraddr=%"PRIsVALUE" state=%s",
16251627
funcname, ret2, errno, peeraddr_ip_str(self), SSL_state_string_long(ssl));
@@ -1904,6 +1906,7 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
19041906
continue;
19051907
#endif
19061908
if (errno) rb_sys_fail(0);
1909+
/* fallthrough */
19071910
default:
19081911
ossl_raise(eSSLError, "SSL_write");
19091912
}

ext/openssl/ossl_ts.c

+21-3
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ obj_to_asn1obj(VALUE obj)
145145
return a1obj;
146146
}
147147

148+
static VALUE
149+
obj_to_asn1obj_i(VALUE obj)
150+
{
151+
return (VALUE)obj_to_asn1obj(obj);
152+
}
153+
148154
static VALUE
149155
get_asn1obj(ASN1_OBJECT *obj)
150156
{
@@ -1078,6 +1084,18 @@ ossl_tsfac_time_cb(struct TS_resp_ctx *ctx, void *data, long *sec, long *usec)
10781084
return 1;
10791085
}
10801086

1087+
static VALUE
1088+
ossl_evp_get_digestbyname_i(VALUE arg)
1089+
{
1090+
return (VALUE)ossl_evp_get_digestbyname(arg);
1091+
}
1092+
1093+
static VALUE
1094+
ossl_obj2bio_i(VALUE arg)
1095+
{
1096+
return (VALUE)ossl_obj2bio((VALUE *)arg);
1097+
}
1098+
10811099
/*
10821100
* Creates a Response with the help of an OpenSSL::PKey, an
10831101
* OpenSSL::X509::Certificate and a Request.
@@ -1146,7 +1164,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
11461164
goto end;
11471165
}
11481166
if (!NIL_P(def_policy_id) && !TS_REQ_get_policy_id(req)) {
1149-
def_policy_id_obj = (ASN1_OBJECT*)rb_protect((VALUE (*)(VALUE))obj_to_asn1obj, (VALUE)def_policy_id, &status);
1167+
def_policy_id_obj = (ASN1_OBJECT*)rb_protect(obj_to_asn1obj_i, (VALUE)def_policy_id, &status);
11501168
if (status)
11511169
goto end;
11521170
}
@@ -1188,7 +1206,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
11881206

11891207
for (i = 0; i < RARRAY_LEN(allowed_digests); i++) {
11901208
rbmd = rb_ary_entry(allowed_digests, i);
1191-
md = (const EVP_MD *)rb_protect((VALUE (*)(VALUE))ossl_evp_get_digestbyname, rbmd, &status);
1209+
md = (const EVP_MD *)rb_protect(ossl_evp_get_digestbyname_i, rbmd, &status);
11921210
if (status)
11931211
goto end;
11941212
TS_RESP_CTX_add_md(ctx, md);
@@ -1199,7 +1217,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
11991217
if (status)
12001218
goto end;
12011219

1202-
req_bio = (BIO*)rb_protect((VALUE (*)(VALUE))ossl_obj2bio, (VALUE)&str, &status);
1220+
req_bio = (BIO*)rb_protect(ossl_obj2bio_i, (VALUE)&str, &status);
12031221
if (status)
12041222
goto end;
12051223

ext/openssl/ossl_x509store.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,15 @@ struct ossl_verify_cb_args {
5252
};
5353

5454
static VALUE
55-
call_verify_cb_proc(struct ossl_verify_cb_args *args)
55+
ossl_x509stctx_new_i(VALUE arg)
5656
{
57+
return ossl_x509stctx_new((X509_STORE_CTX *)arg);
58+
}
59+
60+
static VALUE
61+
call_verify_cb_proc(VALUE arg)
62+
{
63+
struct ossl_verify_cb_args *args = (struct ossl_verify_cb_args *)arg;
5764
return rb_funcall(args->proc, rb_intern("call"), 2,
5865
args->preverify_ok, args->store_ctx);
5966
}
@@ -69,7 +76,7 @@ ossl_verify_cb_call(VALUE proc, int ok, X509_STORE_CTX *ctx)
6976
return ok;
7077

7178
ret = Qfalse;
72-
rctx = rb_protect((VALUE(*)(VALUE))ossl_x509stctx_new, (VALUE)ctx, &state);
79+
rctx = rb_protect(ossl_x509stctx_new_i, (VALUE)ctx, &state);
7380
if (state) {
7481
rb_set_errinfo(Qnil);
7582
rb_warn("StoreContext initialization failure");
@@ -78,7 +85,7 @@ ossl_verify_cb_call(VALUE proc, int ok, X509_STORE_CTX *ctx)
7885
args.proc = proc;
7986
args.preverify_ok = ok ? Qtrue : Qfalse;
8087
args.store_ctx = rctx;
81-
ret = rb_protect((VALUE(*)(VALUE))call_verify_cb_proc, (VALUE)&args, &state);
88+
ret = rb_protect(call_verify_cb_proc, (VALUE)&args, &state);
8289
if (state) {
8390
rb_set_errinfo(Qnil);
8491
rb_warn("exception in verify_callback is ignored");

0 commit comments

Comments
 (0)