Skip to content

Commit 3b3c950

Browse files
authored
Merge pull request #814 from rhenium/ky/extension-make-static
Various small fixes in C extension code
2 parents 3f7b722 + 974c67f commit 3b3c950

40 files changed

+132
-207
lines changed

ext/openssl/ossl.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ ossl_clear_error(void)
355355
* Any errors you see here are probably due to a bug in Ruby's OpenSSL
356356
* implementation.
357357
*/
358-
VALUE
358+
static VALUE
359359
ossl_get_errors(VALUE _)
360360
{
361361
VALUE ary;
@@ -1150,24 +1150,22 @@ Init_openssl(void)
11501150
/*
11511151
* Init components
11521152
*/
1153+
Init_ossl_asn1();
11531154
Init_ossl_bn();
11541155
Init_ossl_cipher();
11551156
Init_ossl_config();
11561157
Init_ossl_digest();
1158+
Init_ossl_engine();
11571159
Init_ossl_hmac();
1160+
Init_ossl_kdf();
11581161
Init_ossl_ns_spki();
1162+
Init_ossl_ocsp();
11591163
Init_ossl_pkcs12();
11601164
Init_ossl_pkcs7();
11611165
Init_ossl_pkey();
1166+
Init_ossl_provider();
11621167
Init_ossl_rand();
11631168
Init_ossl_ssl();
1164-
#ifndef OPENSSL_NO_TS
11651169
Init_ossl_ts();
1166-
#endif
11671170
Init_ossl_x509();
1168-
Init_ossl_ocsp();
1169-
Init_ossl_engine();
1170-
Init_ossl_provider();
1171-
Init_ossl_asn1();
1172-
Init_ossl_kdf();
11731171
}

ext/openssl/ossl.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <openssl/dsa.h>
4646
#include <openssl/evp.h>
4747
#include <openssl/dh.h>
48+
#include "openssl_missing.h"
4849

4950
#ifndef LIBRESSL_VERSION_NUMBER
5051
# define OSSL_IS_LIBRESSL 0
@@ -178,28 +179,25 @@ extern VALUE dOSSL;
178179
/*
179180
* Include all parts
180181
*/
181-
#include "openssl_missing.h"
182182
#include "ossl_asn1.h"
183183
#include "ossl_bio.h"
184184
#include "ossl_bn.h"
185185
#include "ossl_cipher.h"
186186
#include "ossl_config.h"
187187
#include "ossl_digest.h"
188+
#include "ossl_engine.h"
188189
#include "ossl_hmac.h"
190+
#include "ossl_kdf.h"
189191
#include "ossl_ns_spki.h"
190192
#include "ossl_ocsp.h"
191193
#include "ossl_pkcs12.h"
192194
#include "ossl_pkcs7.h"
193195
#include "ossl_pkey.h"
196+
#include "ossl_provider.h"
194197
#include "ossl_rand.h"
195198
#include "ossl_ssl.h"
196-
#ifndef OPENSSL_NO_TS
197-
#include "ossl_ts.h"
198-
#endif
199+
#include "ossl_ts.h"
199200
#include "ossl_x509.h"
200-
#include "ossl_engine.h"
201-
#include "ossl_provider.h"
202-
#include "ossl_kdf.h"
203201

204202
void Init_openssl(void);
205203

ext/openssl/ossl_asn1.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -163,23 +163,23 @@ VALUE mASN1;
163163
VALUE eASN1Error;
164164

165165
VALUE cASN1Data;
166-
VALUE cASN1Primitive;
167-
VALUE cASN1Constructive;
168-
169-
VALUE cASN1EndOfContent;
170-
VALUE cASN1Boolean; /* BOOLEAN */
171-
VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
172-
VALUE cASN1BitString; /* BIT STRING */
173-
VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
174-
VALUE cASN1NumericString, cASN1PrintableString;
175-
VALUE cASN1T61String, cASN1VideotexString;
176-
VALUE cASN1IA5String, cASN1GraphicString;
177-
VALUE cASN1ISO64String, cASN1GeneralString;
178-
VALUE cASN1UniversalString, cASN1BMPString;
179-
VALUE cASN1Null; /* NULL */
180-
VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
181-
VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
182-
VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
166+
static VALUE cASN1Primitive;
167+
static VALUE cASN1Constructive;
168+
169+
static VALUE cASN1EndOfContent;
170+
static VALUE cASN1Boolean; /* BOOLEAN */
171+
static VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
172+
static VALUE cASN1BitString; /* BIT STRING */
173+
static VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
174+
static VALUE cASN1NumericString, cASN1PrintableString;
175+
static VALUE cASN1T61String, cASN1VideotexString;
176+
static VALUE cASN1IA5String, cASN1GraphicString;
177+
static VALUE cASN1ISO64String, cASN1GeneralString;
178+
static VALUE cASN1UniversalString, cASN1BMPString;
179+
static VALUE cASN1Null; /* NULL */
180+
static VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
181+
static VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
182+
static VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
183183

184184
static VALUE sym_IMPLICIT, sym_EXPLICIT;
185185
static VALUE sym_UNIVERSAL, sym_APPLICATION, sym_CONTEXT_SPECIFIC, sym_PRIVATE;

ext/openssl/ossl_asn1.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,6 @@ extern VALUE mASN1;
3838
extern VALUE eASN1Error;
3939

4040
extern VALUE cASN1Data;
41-
extern VALUE cASN1Primitive;
42-
extern VALUE cASN1Constructive;
43-
44-
extern VALUE cASN1Boolean; /* BOOLEAN */
45-
extern VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
46-
extern VALUE cASN1BitString; /* BIT STRING */
47-
extern VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
48-
extern VALUE cASN1NumericString, cASN1PrintableString;
49-
extern VALUE cASN1T61String, cASN1VideotexString;
50-
extern VALUE cASN1IA5String, cASN1GraphicString;
51-
extern VALUE cASN1ISO64String, cASN1GeneralString;
52-
extern VALUE cASN1UniversalString, cASN1BMPString;
53-
extern VALUE cASN1Null; /* NULL */
54-
extern VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
55-
extern VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
56-
extern VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
57-
58-
extern VALUE cASN1EndOfContent; /* END OF CONTENT */
5941

6042
void Init_ossl_asn1(void);
6143

ext/openssl/ossl_bn.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ VALUE cBN;
4949
*
5050
* Generic Error for all of OpenSSL::BN (big num)
5151
*/
52-
VALUE eBNError;
52+
static VALUE eBNError;
5353

5454
/*
5555
* Public
@@ -152,19 +152,19 @@ ossl_bn_value_ptr(volatile VALUE *ptr)
152152
*/
153153

154154
#ifdef HAVE_RB_EXT_RACTOR_SAFE
155-
void
155+
static void
156156
ossl_bn_ctx_free(void *ptr)
157157
{
158158
BN_CTX *ctx = (BN_CTX *)ptr;
159159
BN_CTX_free(ctx);
160160
}
161161

162-
struct rb_ractor_local_storage_type ossl_bn_ctx_key_type = {
162+
static struct rb_ractor_local_storage_type ossl_bn_ctx_key_type = {
163163
NULL, // mark
164164
ossl_bn_ctx_free,
165165
};
166166

167-
rb_ractor_local_key_t ossl_bn_ctx_key;
167+
static rb_ractor_local_key_t ossl_bn_ctx_key;
168168

169169
BN_CTX *
170170
ossl_bn_ctx_get(void)

ext/openssl/ossl_bn.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#define _OSSL_BN_H_
1212

1313
extern VALUE cBN;
14-
extern VALUE eBNError;
1514

1615
BN_CTX *ossl_bn_ctx_get(void);
1716
#define ossl_bn_ctx ossl_bn_ctx_get()

ext/openssl/ossl_cipher.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
/*
3131
* Classes
3232
*/
33-
VALUE cCipher;
34-
VALUE eCipherError;
33+
static VALUE cCipher;
34+
static VALUE eCipherError;
3535
static ID id_auth_tag_len, id_key_set;
3636

3737
static VALUE ossl_cipher_alloc(VALUE klass);

ext/openssl/ossl_cipher.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
#if !defined(_OSSL_CIPHER_H_)
1111
#define _OSSL_CIPHER_H_
1212

13-
extern VALUE cCipher;
14-
extern VALUE eCipherError;
15-
1613
const EVP_CIPHER *ossl_evp_get_cipherbyname(VALUE);
1714
VALUE ossl_cipher_new(const EVP_CIPHER *);
1815
void Init_ossl_cipher(void);

ext/openssl/ossl_digest.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
/*
2020
* Classes
2121
*/
22-
VALUE cDigest;
23-
VALUE eDigestError;
22+
static VALUE cDigest;
23+
static VALUE eDigestError;
2424

2525
static VALUE ossl_digest_alloc(VALUE klass);
2626

@@ -96,7 +96,7 @@ ossl_digest_alloc(VALUE klass)
9696
return TypedData_Wrap_Struct(klass, &ossl_digest_type, 0);
9797
}
9898

99-
VALUE ossl_digest_update(VALUE, VALUE);
99+
static VALUE ossl_digest_update(VALUE, VALUE);
100100

101101
/*
102102
* call-seq:
@@ -225,7 +225,7 @@ ossl_digest_reset(VALUE self)
225225
* result = digest.digest
226226
*
227227
*/
228-
VALUE
228+
static VALUE
229229
ossl_digest_update(VALUE self, VALUE data)
230230
{
231231
EVP_MD_CTX *ctx;

ext/openssl/ossl_digest.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
#if !defined(_OSSL_DIGEST_H_)
1111
#define _OSSL_DIGEST_H_
1212

13-
extern VALUE cDigest;
14-
extern VALUE eDigestError;
15-
1613
const EVP_MD *ossl_evp_get_digestbyname(VALUE);
1714
VALUE ossl_digest_new(const EVP_MD *);
1815
void Init_ossl_digest(void);

0 commit comments

Comments
 (0)