Skip to content

Commit 85d6b7f

Browse files
committed
Mark variables and functions as static whenever possible
1 parent a424aad commit 85d6b7f

36 files changed

+71
-149
lines changed

ext/openssl/ossl.c

Lines changed: 1 addition & 1 deletion
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;

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
@@ -53,7 +53,7 @@ VALUE cBN;
5353
*
5454
* Generic Error for all of OpenSSL::BN (big num)
5555
*/
56-
VALUE eBNError;
56+
static VALUE eBNError;
5757

5858
/*
5959
* Public
@@ -156,19 +156,19 @@ ossl_bn_value_ptr(volatile VALUE *ptr)
156156
*/
157157

158158
#ifdef HAVE_RB_EXT_RACTOR_SAFE
159-
void
159+
static void
160160
ossl_bn_ctx_free(void *ptr)
161161
{
162162
BN_CTX *ctx = (BN_CTX *)ptr;
163163
BN_CTX_free(ctx);
164164
}
165165

166-
struct rb_ractor_local_storage_type ossl_bn_ctx_key_type = {
166+
static struct rb_ractor_local_storage_type ossl_bn_ctx_key_type = {
167167
NULL, // mark
168168
ossl_bn_ctx_free,
169169
};
170170

171-
rb_ractor_local_key_t ossl_bn_ctx_key;
171+
static rb_ractor_local_key_t ossl_bn_ctx_key;
172172

173173
BN_CTX *
174174
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);

ext/openssl/ossl_engine.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
*
3838
* See also, https://www.openssl.org/docs/crypto/engine.html
3939
*/
40-
VALUE cEngine;
40+
static VALUE cEngine;
4141
/* Document-class: OpenSSL::Engine::EngineError
4242
*
4343
* This is the generic exception for OpenSSL::Engine related errors
4444
*/
45-
VALUE eEngineError;
45+
static VALUE eEngineError;
4646

4747
/*
4848
* Private

0 commit comments

Comments
 (0)