ruby-changes:4120
From: ko1@a...
Date: Tue, 26 Feb 2008 16:07:49 +0900 (JST)
Subject: [ruby-changes:4120] technorama - Ruby:r15610 (trunk): * ext/openssl/ossl_{ec,dh,dsa,rsa}.c: Remove useless warnings.
technorama 2008-02-26 16:07:26 +0900 (Tue, 26 Feb 2008) New Revision: 15610 Modified files: trunk/ChangeLog trunk/ext/openssl/ossl_asn1.c trunk/ext/openssl/ossl_pkey_dh.c trunk/ext/openssl/ossl_pkey_dsa.c trunk/ext/openssl/ossl_pkey_ec.c trunk/ext/openssl/ossl_pkey_rsa.c trunk/ext/openssl/ossl_ssl_session.c Log: * ext/openssl/ossl_{ec,dh,dsa,rsa}.c: Remove useless warnings. * ext/openssl/ossl_asn1.c: Simplify code. * ext/openssl/ossl_ssl_session.c Fix compiler warnings. Undefine #id if SSL_SESSION_get_id is not supported. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/openssl/ossl_pkey_dh.c?r1=15610&r2=15609&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15610&r2=15609&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/openssl/ossl_asn1.c?r1=15610&r2=15609&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/openssl/ossl_ssl_session.c?r1=15610&r2=15609&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/openssl/ossl_pkey_ec.c?r1=15610&r2=15609&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/openssl/ossl_pkey_dsa.c?r1=15610&r2=15609&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/openssl/ossl_pkey_rsa.c?r1=15610&r2=15609&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15609) +++ ChangeLog (revision 15610) @@ -1,3 +1,12 @@ +Tue Feb 26 16:06:00 2008 Technorama Ltd. <oss-ruby@t...> + + * ext/openssl/ossl_{ec,dh,dsa,rsa}.c: Remove useless warnings. + + * ext/openssl/ossl_asn1.c: Simplify code. + + * ext/openssl/ossl_ssl_session.c Fix compiler warnings. + Undefine #id if SSL_SESSION_get_id is not supported. + Tue Feb 26 15:50:10 2008 Nobuyoshi Nakada <nobu@r...> * parse.y (value_expr_gen): removed inappropriate warning. Index: ext/openssl/ossl_pkey_dsa.c =================================================================== --- ext/openssl/ossl_pkey_dsa.c (revision 15609) +++ ext/openssl/ossl_pkey_dsa.c (revision 15610) @@ -477,12 +477,8 @@ } #else /* defined NO_DSA */ -# warning >>> OpenSSL is compiled without DSA support <<< - void Init_ossl_dsa() { - rb_warning("OpenSSL is compiled without DSA support"); } - #endif /* NO_DSA */ Index: ext/openssl/ossl_pkey_rsa.c =================================================================== --- ext/openssl/ossl_pkey_rsa.c (revision 15609) +++ ext/openssl/ossl_pkey_rsa.c (revision 15610) @@ -585,11 +585,9 @@ } #else /* defined NO_RSA */ -# warning >>> OpenSSL is compiled without RSA support <<< void Init_ossl_rsa() { - rb_warning("OpenSSL is compiled without RSA support"); } #endif /* NO_RSA */ Index: ext/openssl/ossl_pkey_ec.c =================================================================== --- ext/openssl/ossl_pkey_ec.c (revision 15609) +++ ext/openssl/ossl_pkey_ec.c (revision 15610) @@ -1576,10 +1576,7 @@ } #else /* defined NO_EC */ -# warning >>> OpenSSL is compiled without EC support <<< - void Init_ossl_ec() { } - #endif /* NO_EC */ Index: ext/openssl/ossl_asn1.c =================================================================== --- ext/openssl/ossl_asn1.c (revision 15609) +++ ext/openssl/ossl_asn1.c (revision 15610) @@ -347,16 +347,11 @@ if(!(bstr = d2i_ASN1_BIT_STRING(NULL, &p, length))) ossl_raise(eASN1Error, NULL); len = bstr->length; - if(!(buf = OPENSSL_malloc(len))){ - ASN1_BIT_STRING_free(bstr); - ossl_raise(eASN1Error, NULL); - } *unused_bits = 0; if(bstr->flags & ASN1_STRING_FLAG_BITS_LEFT) *unused_bits = bstr->flags & 0x07; - memcpy(buf, bstr->data, len); + ret = rb_str_new(bstr->data, len); ASN1_BIT_STRING_free(bstr); - ret = ossl_buf2str(buf, len); return ret; } @@ -925,7 +920,7 @@ { ASN1_TYPE *asn1; int tn, tc, explicit; - long length, reallen; + long len, reallen; unsigned char *buf, *p; VALUE str; @@ -934,26 +929,24 @@ explicit = ossl_asn1_is_explicit(self); asn1 = ossl_asn1_get_asn1type(self); - length = ASN1_object_size(1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn); - if(!(buf = OPENSSL_malloc(length))){ + len = ASN1_object_size(1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn); + if(!(buf = OPENSSL_malloc(len))){ ossl_ASN1_TYPE_free(asn1); ossl_raise(eASN1Error, "cannot alloc buffer"); } p = buf; - if(tc == V_ASN1_UNIVERSAL) ossl_i2d_ASN1_TYPE(asn1, &p); - else{ - if(explicit){ - ASN1_put_object(&p, 1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn, tc); - ossl_i2d_ASN1_TYPE(asn1, &p); - } - else{ - ossl_i2d_ASN1_TYPE(asn1, &p); - *buf = tc | tn | (*buf & V_ASN1_CONSTRUCTED); - } + if (tc == V_ASN1_UNIVERSAL) { + ossl_i2d_ASN1_TYPE(asn1, &p); + } else if (explicit) { + ASN1_put_object(&p, 1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn, tc); + ossl_i2d_ASN1_TYPE(asn1, &p); + } else { + ossl_i2d_ASN1_TYPE(asn1, &p); + *buf = tc | tn | (*buf & V_ASN1_CONSTRUCTED); } ossl_ASN1_TYPE_free(asn1); reallen = p - buf; - assert(reallen <= length); + assert(reallen <= len); str = ossl_buf2str(buf, reallen); /* buf will be free in ossl_buf2str */ return str; Index: ext/openssl/ossl_ssl_session.c =================================================================== --- ext/openssl/ossl_ssl_session.c (revision 15609) +++ ext/openssl/ossl_ssl_session.c (revision 15610) @@ -174,7 +174,7 @@ p = SSL_SESSION_get_id(ctx, &i); - return rb_str_new(p, i); + return rb_str_new((const char *) p, i); } #endif @@ -200,7 +200,7 @@ else if (len >= sizeof(buf)) ossl_raise(eSSLSession, "i2d_SSL_SESSION too large"); - return rb_str_new(p, len); + return rb_str_new((const char *) p, len); } /* @@ -289,6 +289,8 @@ #ifdef HAVE_SSL_SESSION_GET_ID rb_define_method(cSSLSession, "id", ossl_ssl_session_get_id, 0); +#else + rb_undef_method(cSSLSession, "id"); #endif rb_define_method(cSSLSession, "to_der", ossl_ssl_session_to_der, 0); rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0); Index: ext/openssl/ossl_pkey_dh.c =================================================================== --- ext/openssl/ossl_pkey_dh.c (revision 15609) +++ ext/openssl/ossl_pkey_dh.c (revision 15610) @@ -524,11 +524,9 @@ } #else /* defined NO_DH */ -# warning >>> OpenSSL is compiled without DH support <<< void Init_ossl_dh() { - rb_warning("OpenSSL is compiled without DH support"); } #endif /* NO_DH */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/