Fix miscellaneous clang-tidy warnings.
There are still a ton of them, almost exclusively complaints that
function declaration and definitions have different parameter names. I
just fixed a few randomly.
Change-Id: I1072f3dba8f63372cda92425aa94f4aa9e3911fa
Reviewed-on: https://boringssl-review.googlesource.com/18706
Reviewed-by: Steven Valdez <svaldez@google.com>
diff --git a/crypto/asn1/asn1_locl.h b/crypto/asn1/asn1_locl.h
index ce8146b..fef00ac 100644
--- a/crypto/asn1/asn1_locl.h
+++ b/crypto/asn1/asn1_locl.h
@@ -72,7 +72,7 @@
/* Wrapper functions for time functions. */
/* OPENSSL_gmtime wraps |gmtime_r|. See the manual page for that function. */
-struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);
+struct tm *OPENSSL_gmtime(const time_t *time, struct tm *result);
/* OPENSSL_gmtime_adj updates |tm| by adding |offset_day| days and |offset_sec|
* seconds. */
diff --git a/crypto/asn1/time_support.c b/crypto/asn1/time_support.c
index 194dc3a..3efd43e 100644
--- a/crypto/asn1/time_support.c
+++ b/crypto/asn1/time_support.c
@@ -171,7 +171,7 @@
return 1;
}
-int OPENSSL_gmtime_diff(int *pday, int *psec, const struct tm *from,
+int OPENSSL_gmtime_diff(int *out_days, int *out_secs, const struct tm *from,
const struct tm *to) {
int from_sec, to_sec, diff_sec;
long from_jd, to_jd, diff_day;
@@ -195,11 +195,11 @@
diff_sec -= SECS_PER_DAY;
}
- if (pday) {
- *pday = (int)diff_day;
+ if (out_days) {
+ *out_days = (int)diff_day;
}
- if (psec) {
- *psec = diff_sec;
+ if (out_secs) {
+ *out_secs = diff_sec;
}
return 1;
diff --git a/crypto/buf/buf.c b/crypto/buf/buf.c
index ca1d70b..f1fcae6 100644
--- a/crypto/buf/buf.c
+++ b/crypto/buf/buf.c
@@ -153,12 +153,12 @@
return buf_mem_grow(buf, len, 1 /* clear old buffer contents. */);
}
-char *BUF_strdup(const char *buf) {
- if (buf == NULL) {
+char *BUF_strdup(const char *str) {
+ if (str == NULL) {
return NULL;
}
- return BUF_strndup(buf, strlen(buf));
+ return BUF_strndup(str, strlen(str));
}
size_t BUF_strnlen(const char *str, size_t max_len) {
@@ -173,15 +173,15 @@
return i;
}
-char *BUF_strndup(const char *buf, size_t size) {
+char *BUF_strndup(const char *str, size_t size) {
char *ret;
size_t alloc_size;
- if (buf == NULL) {
+ if (str == NULL) {
return NULL;
}
- size = BUF_strnlen(buf, size);
+ size = BUF_strnlen(str, size);
alloc_size = size + 1;
if (alloc_size < size) {
@@ -195,7 +195,7 @@
return NULL;
}
- OPENSSL_memcpy(ret, buf, size);
+ OPENSSL_memcpy(ret, str, size);
ret[size] = '\0';
return ret;
}
@@ -223,19 +223,17 @@
return l + BUF_strlcpy(dst, src, dst_size);
}
-void *BUF_memdup(const void *data, size_t dst_size) {
- void *ret;
-
- if (dst_size == 0) {
+void *BUF_memdup(const void *data, size_t size) {
+ if (size == 0) {
return NULL;
}
- ret = OPENSSL_malloc(dst_size);
+ void *ret = OPENSSL_malloc(size);
if (ret == NULL) {
OPENSSL_PUT_ERROR(BUF, ERR_R_MALLOC_FAILURE);
return NULL;
}
- OPENSSL_memcpy(ret, data, dst_size);
+ OPENSSL_memcpy(ret, data, size);
return ret;
}
diff --git a/crypto/dh/check.c b/crypto/dh/check.c
index e3c111b..55fc1c3 100644
--- a/crypto/dh/check.c
+++ b/crypto/dh/check.c
@@ -59,8 +59,8 @@
#include <openssl/bn.h>
-int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret) {
- *ret = 0;
+int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *out_flags) {
+ *out_flags = 0;
BN_CTX *ctx = BN_CTX_new();
if (ctx == NULL) {
@@ -77,7 +77,7 @@
goto err;
}
if (BN_cmp(pub_key, tmp) <= 0) {
- *ret |= DH_CHECK_PUBKEY_TOO_SMALL;
+ *out_flags |= DH_CHECK_PUBKEY_TOO_SMALL;
}
/* Check |pub_key| is less than |dh->p| - 1. */
@@ -86,7 +86,7 @@
goto err;
}
if (BN_cmp(pub_key, tmp) >= 0) {
- *ret |= DH_CHECK_PUBKEY_TOO_LARGE;
+ *out_flags |= DH_CHECK_PUBKEY_TOO_LARGE;
}
if (dh->q != NULL) {
@@ -97,7 +97,7 @@
goto err;
}
if (!BN_is_one(tmp)) {
- *ret |= DH_CHECK_PUBKEY_INVALID;
+ *out_flags |= DH_CHECK_PUBKEY_INVALID;
}
}
@@ -110,7 +110,7 @@
}
-int DH_check(const DH *dh, int *ret) {
+int DH_check(const DH *dh, int *out_flags) {
/* Check that p is a safe prime and if g is 2, 3 or 5, check that it is a
* suitable generator where:
* for 2, p mod 24 == 11
@@ -123,7 +123,7 @@
BN_ULONG l;
BIGNUM *t1 = NULL, *t2 = NULL;
- *ret = 0;
+ *out_flags = 0;
ctx = BN_CTX_new();
if (ctx == NULL) {
goto err;
@@ -140,16 +140,16 @@
if (dh->q) {
if (BN_cmp(dh->g, BN_value_one()) <= 0) {
- *ret |= DH_CHECK_NOT_SUITABLE_GENERATOR;
+ *out_flags |= DH_CHECK_NOT_SUITABLE_GENERATOR;
} else if (BN_cmp(dh->g, dh->p) >= 0) {
- *ret |= DH_CHECK_NOT_SUITABLE_GENERATOR;
+ *out_flags |= DH_CHECK_NOT_SUITABLE_GENERATOR;
} else {
/* Check g^q == 1 mod p */
if (!BN_mod_exp_mont(t1, dh->g, dh->q, dh->p, ctx, NULL)) {
goto err;
}
if (!BN_is_one(t1)) {
- *ret |= DH_CHECK_NOT_SUITABLE_GENERATOR;
+ *out_flags |= DH_CHECK_NOT_SUITABLE_GENERATOR;
}
}
r = BN_is_prime_ex(dh->q, BN_prime_checks, ctx, NULL);
@@ -157,17 +157,17 @@
goto err;
}
if (!r) {
- *ret |= DH_CHECK_Q_NOT_PRIME;
+ *out_flags |= DH_CHECK_Q_NOT_PRIME;
}
/* Check p == 1 mod q i.e. q divides p - 1 */
if (!BN_div(t1, t2, dh->p, dh->q, ctx)) {
goto err;
}
if (!BN_is_one(t2)) {
- *ret |= DH_CHECK_INVALID_Q_VALUE;
+ *out_flags |= DH_CHECK_INVALID_Q_VALUE;
}
if (dh->j && BN_cmp(dh->j, t1)) {
- *ret |= DH_CHECK_INVALID_J_VALUE;
+ *out_flags |= DH_CHECK_INVALID_J_VALUE;
}
} else if (BN_is_word(dh->g, DH_GENERATOR_2)) {
l = BN_mod_word(dh->p, 24);
@@ -175,7 +175,7 @@
goto err;
}
if (l != 11) {
- *ret |= DH_CHECK_NOT_SUITABLE_GENERATOR;
+ *out_flags |= DH_CHECK_NOT_SUITABLE_GENERATOR;
}
} else if (BN_is_word(dh->g, DH_GENERATOR_5)) {
l = BN_mod_word(dh->p, 10);
@@ -183,10 +183,10 @@
goto err;
}
if (l != 3 && l != 7) {
- *ret |= DH_CHECK_NOT_SUITABLE_GENERATOR;
+ *out_flags |= DH_CHECK_NOT_SUITABLE_GENERATOR;
}
} else {
- *ret |= DH_CHECK_UNABLE_TO_CHECK_GENERATOR;
+ *out_flags |= DH_CHECK_UNABLE_TO_CHECK_GENERATOR;
}
r = BN_is_prime_ex(dh->p, BN_prime_checks, ctx, NULL);
@@ -194,7 +194,7 @@
goto err;
}
if (!r) {
- *ret |= DH_CHECK_P_NOT_PRIME;
+ *out_flags |= DH_CHECK_P_NOT_PRIME;
} else if (!dh->q) {
if (!BN_rshift1(t1, dh->p)) {
goto err;
@@ -204,7 +204,7 @@
goto err;
}
if (!r) {
- *ret |= DH_CHECK_P_NOT_SAFE_PRIME;
+ *out_flags |= DH_CHECK_P_NOT_SAFE_PRIME;
}
}
ok = 1;
diff --git a/crypto/dsa/dsa.c b/crypto/dsa/dsa.c
index 58126c3..d445f14 100644
--- a/crypto/dsa/dsa.c
+++ b/crypto/dsa/dsa.c
@@ -917,35 +917,35 @@
return index;
}
-int DSA_set_ex_data(DSA *d, int idx, void *arg) {
- return CRYPTO_set_ex_data(&d->ex_data, idx, arg);
+int DSA_set_ex_data(DSA *dsa, int idx, void *arg) {
+ return CRYPTO_set_ex_data(&dsa->ex_data, idx, arg);
}
-void *DSA_get_ex_data(const DSA *d, int idx) {
- return CRYPTO_get_ex_data(&d->ex_data, idx);
+void *DSA_get_ex_data(const DSA *dsa, int idx) {
+ return CRYPTO_get_ex_data(&dsa->ex_data, idx);
}
-DH *DSA_dup_DH(const DSA *r) {
- DH *ret = NULL;
-
- if (r == NULL) {
- goto err;
+DH *DSA_dup_DH(const DSA *dsa) {
+ if (dsa == NULL) {
+ return NULL;
}
- ret = DH_new();
+
+ DH *ret = DH_new();
if (ret == NULL) {
goto err;
}
- if (r->q != NULL) {
- ret->priv_length = BN_num_bits(r->q);
- if ((ret->q = BN_dup(r->q)) == NULL) {
+ if (dsa->q != NULL) {
+ ret->priv_length = BN_num_bits(dsa->q);
+ if ((ret->q = BN_dup(dsa->q)) == NULL) {
goto err;
}
}
- if ((r->p != NULL && (ret->p = BN_dup(r->p)) == NULL) ||
- (r->g != NULL && (ret->g = BN_dup(r->g)) == NULL) ||
- (r->pub_key != NULL && (ret->pub_key = BN_dup(r->pub_key)) == NULL) ||
- (r->priv_key != NULL && (ret->priv_key = BN_dup(r->priv_key)) == NULL)) {
- goto err;
+ if ((dsa->p != NULL && (ret->p = BN_dup(dsa->p)) == NULL) ||
+ (dsa->g != NULL && (ret->g = BN_dup(dsa->g)) == NULL) ||
+ (dsa->pub_key != NULL && (ret->pub_key = BN_dup(dsa->pub_key)) == NULL) ||
+ (dsa->priv_key != NULL &&
+ (ret->priv_key = BN_dup(dsa->priv_key)) == NULL)) {
+ goto err;
}
return ret;
diff --git a/crypto/fipsmodule/rand/ctrdrbg_test.cc b/crypto/fipsmodule/rand/ctrdrbg_test.cc
index bd84782..0cc48b1 100644
--- a/crypto/fipsmodule/rand/ctrdrbg_test.cc
+++ b/crypto/fipsmodule/rand/ctrdrbg_test.cc
@@ -100,19 +100,19 @@
CTR_DRBG_STATE drbg;
CTR_DRBG_init(&drbg, seed.data(),
- personalisation.size() > 0 ? personalisation.data() : nullptr,
+ personalisation.empty() ? nullptr : personalisation.data(),
personalisation.size());
CTR_DRBG_reseed(&drbg, reseed.data(),
- ai_reseed.size() > 0 ? ai_reseed.data() : nullptr,
+ ai_reseed.empty() ? nullptr : ai_reseed.data(),
ai_reseed.size());
std::vector<uint8_t> out;
out.resize(expected.size());
CTR_DRBG_generate(&drbg, out.data(), out.size(),
- ai1.size() > 0 ? ai1.data() : nullptr, ai1.size());
+ ai1.empty() ? nullptr : ai1.data(), ai1.size());
CTR_DRBG_generate(&drbg, out.data(), out.size(),
- ai2.size() > 0 ? ai2.data() : nullptr, ai2.size());
+ ai2.empty() ? nullptr : ai2.data(), ai2.size());
EXPECT_EQ(Bytes(expected), Bytes(out));
});
diff --git a/crypto/fipsmodule/rand/rand.c b/crypto/fipsmodule/rand/rand.c
index eb99f72..9480ddb 100644
--- a/crypto/fipsmodule/rand/rand.c
+++ b/crypto/fipsmodule/rand/rand.c
@@ -345,8 +345,6 @@
#if defined(BORINGSSL_FIPS)
CRYPTO_STATIC_MUTEX_unlock_read(thread_states_list_lock_bss_get());
#endif
-
- return;
}
int RAND_bytes(uint8_t *out, size_t out_len) {
diff --git a/crypto/fipsmodule/rsa/rsa.c b/crypto/fipsmodule/rsa/rsa.c
index 21dcacd..a434cb1 100644
--- a/crypto/fipsmodule/rsa/rsa.c
+++ b/crypto/fipsmodule/rsa/rsa.c
@@ -293,12 +293,12 @@
return index;
}
-int RSA_set_ex_data(RSA *d, int idx, void *arg) {
- return CRYPTO_set_ex_data(&d->ex_data, idx, arg);
+int RSA_set_ex_data(RSA *rsa, int idx, void *arg) {
+ return CRYPTO_set_ex_data(&rsa->ex_data, idx, arg);
}
-void *RSA_get_ex_data(const RSA *d, int idx) {
- return CRYPTO_get_ex_data(&d->ex_data, idx);
+void *RSA_get_ex_data(const RSA *rsa, int idx) {
+ return CRYPTO_get_ex_data(&rsa->ex_data, idx);
}
/* SSL_SIG_LENGTH is the size of an SSL/TLS (prior to TLS 1.2) signature: it's
diff --git a/crypto/test/file_test.cc b/crypto/test/file_test.cc
index c85fac6..ea1fc3c 100644
--- a/crypto/test/file_test.cc
+++ b/crypto/test/file_test.cc
@@ -32,7 +32,8 @@
FileTest::FileTest(std::unique_ptr<FileTest::LineReader> reader,
std::function<void(const std::string &)> comment_callback)
- : reader_(std::move(reader)), comment_callback_(comment_callback) {}
+ : reader_(std::move(reader)),
+ comment_callback_(std::move(comment_callback)) {}
FileTest::~FileTest() {}
diff --git a/include/openssl/bio.h b/include/openssl/bio.h
index 2d0d959..9a80cd5 100644
--- a/include/openssl/bio.h
+++ b/include/openssl/bio.h
@@ -79,9 +79,9 @@
DEFINE_STACK_OF(BIO)
-/* BIO_new creates a new BIO with the given type and a reference count of one.
+/* BIO_new creates a new BIO with the given method and a reference count of one.
* It returns the fresh |BIO|, or NULL on error. */
-OPENSSL_EXPORT BIO *BIO_new(const BIO_METHOD *type);
+OPENSSL_EXPORT BIO *BIO_new(const BIO_METHOD *method);
/* BIO_free decrements the reference count of |bio|. If the reference count
* drops to zero, it (optionally) calls the BIO's callback with |BIO_CB_FREE|,
diff --git a/include/openssl/buf.h b/include/openssl/buf.h
index 30f3af7..013c546 100644
--- a/include/openssl/buf.h
+++ b/include/openssl/buf.h
@@ -91,7 +91,7 @@
/* BUF_MEM_grow_clean acts the same as |BUF_MEM_grow|, but clears the previous
* contents of memory if reallocing. */
-OPENSSL_EXPORT size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
+OPENSSL_EXPORT size_t BUF_MEM_grow_clean(BUF_MEM *buf, size_t len);
/* BUF_strdup returns an allocated, duplicate of |str|. */
OPENSSL_EXPORT char *BUF_strdup(const char *str);
@@ -112,7 +112,7 @@
OPENSSL_EXPORT size_t BUF_strlcpy(char *dst, const char *src, size_t dst_size);
/* BUF_strlcat acts like strlcat(3). */
-OPENSSL_EXPORT size_t BUF_strlcat(char *dst, const char *src, size_t size);
+OPENSSL_EXPORT size_t BUF_strlcat(char *dst, const char *src, size_t dst_size);
#if defined(__cplusplus)
diff --git a/include/openssl/curve25519.h b/include/openssl/curve25519.h
index 97be067..11fc25e 100644
--- a/include/openssl/curve25519.h
+++ b/include/openssl/curve25519.h
@@ -50,7 +50,7 @@
* public values as inputs. */
OPENSSL_EXPORT int X25519(uint8_t out_shared_key[32],
const uint8_t private_key[32],
- const uint8_t peers_public_value[32]);
+ const uint8_t peer_public_value[32]);
/* X25519_public_from_private calculates a Diffie-Hellman public value from the
* given private key and writes it to |out_public_value|. */
diff --git a/include/openssl/dsa.h b/include/openssl/dsa.h
index afe0291..f992b91 100644
--- a/include/openssl/dsa.h
+++ b/include/openssl/dsa.h
@@ -298,8 +298,8 @@
CRYPTO_EX_unused *unused,
CRYPTO_EX_dup *dup_unused,
CRYPTO_EX_free *free_func);
-OPENSSL_EXPORT int DSA_set_ex_data(DSA *d, int idx, void *arg);
-OPENSSL_EXPORT void *DSA_get_ex_data(const DSA *d, int idx);
+OPENSSL_EXPORT int DSA_set_ex_data(DSA *dsa, int idx, void *arg);
+OPENSSL_EXPORT void *DSA_get_ex_data(const DSA *dsa, int idx);
/* Deprecated functions. */
diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h
index a580f97..ed2c0be 100644
--- a/include/openssl/rsa.h
+++ b/include/openssl/rsa.h
@@ -456,8 +456,8 @@
CRYPTO_EX_unused *unused,
CRYPTO_EX_dup *dup_unused,
CRYPTO_EX_free *free_func);
-OPENSSL_EXPORT int RSA_set_ex_data(RSA *r, int idx, void *arg);
-OPENSSL_EXPORT void *RSA_get_ex_data(const RSA *r, int idx);
+OPENSSL_EXPORT int RSA_set_ex_data(RSA *rsa, int idx, void *arg);
+OPENSSL_EXPORT void *RSA_get_ex_data(const RSA *rsa, int idx);
/* Flags. */
diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h
index 6bbf15d..6341fa9 100644
--- a/include/openssl/ssl.h
+++ b/include/openssl/ssl.h
@@ -2819,20 +2819,17 @@
* The callback returns the length of the PSK or 0 if no suitable identity was
* found. */
OPENSSL_EXPORT void SSL_CTX_set_psk_client_callback(
- SSL_CTX *ctx,
- unsigned (*psk_client_callback)(
- SSL *ssl, const char *hint, char *identity,
- unsigned max_identity_len, uint8_t *psk, unsigned max_psk_len));
+ SSL_CTX *ctx, unsigned (*cb)(SSL *ssl, const char *hint, char *identity,
+ unsigned max_identity_len, uint8_t *psk,
+ unsigned max_psk_len));
/* SSL_set_psk_client_callback sets the callback to be called when PSK is
* negotiated on the client. This callback must be set to enable PSK cipher
* suites on the client. See also |SSL_CTX_set_psk_client_callback|. */
OPENSSL_EXPORT void SSL_set_psk_client_callback(
- SSL *ssl, unsigned (*psk_client_callback)(SSL *ssl, const char *hint,
- char *identity,
- unsigned max_identity_len,
- uint8_t *psk,
- unsigned max_psk_len));
+ SSL *ssl, unsigned (*cb)(SSL *ssl, const char *hint, char *identity,
+ unsigned max_identity_len, uint8_t *psk,
+ unsigned max_psk_len));
/* SSL_CTX_set_psk_server_callback sets the callback to be called when PSK is
* negotiated on the server. This callback must be set to enable PSK cipher
@@ -2842,19 +2839,15 @@
* length at most |max_psk_len| to |psk| and return the number of bytes written
* or zero if the PSK identity is unknown. */
OPENSSL_EXPORT void SSL_CTX_set_psk_server_callback(
- SSL_CTX *ctx,
- unsigned (*psk_server_callback)(SSL *ssl, const char *identity,
- uint8_t *psk,
- unsigned max_psk_len));
+ SSL_CTX *ctx, unsigned (*cb)(SSL *ssl, const char *identity, uint8_t *psk,
+ unsigned max_psk_len));
/* SSL_set_psk_server_callback sets the callback to be called when PSK is
* negotiated on the server. This callback must be set to enable PSK cipher
* suites on the server. See also |SSL_CTX_set_psk_server_callback|. */
OPENSSL_EXPORT void SSL_set_psk_server_callback(
- SSL *ssl,
- unsigned (*psk_server_callback)(SSL *ssl, const char *identity,
- uint8_t *psk,
- unsigned max_psk_len));
+ SSL *ssl, unsigned (*cb)(SSL *ssl, const char *identity, uint8_t *psk,
+ unsigned max_psk_len));
/* SSL_CTX_use_psk_identity_hint configures server connections to advertise an
* identity hint of |identity_hint|. It returns one on success and zero on
@@ -3572,7 +3565,7 @@
OPENSSL_EXPORT int SSL_CTX_sess_cache_full(const SSL_CTX *ctx);
/* SSL_cutthrough_complete calls |SSL_in_false_start|. */
-OPENSSL_EXPORT int SSL_cutthrough_complete(const SSL *s);
+OPENSSL_EXPORT int SSL_cutthrough_complete(const SSL *ssl);
/* SSL_num_renegotiations calls |SSL_total_renegotiations|. */
OPENSSL_EXPORT int SSL_num_renegotiations(const SSL *ssl);
@@ -3596,10 +3589,10 @@
OPENSSL_EXPORT void SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes);
/* SSL_get_read_ahead returns zero. */
-OPENSSL_EXPORT int SSL_get_read_ahead(const SSL *s);
+OPENSSL_EXPORT int SSL_get_read_ahead(const SSL *ssl);
/* SSL_set_read_ahead does nothing. */
-OPENSSL_EXPORT void SSL_set_read_ahead(SSL *s, int yes);
+OPENSSL_EXPORT void SSL_set_read_ahead(SSL *ssl, int yes);
/* SSL_renegotiate put an error on the error queue and returns zero. */
OPENSSL_EXPORT int SSL_renegotiate(SSL *ssl);
@@ -3664,10 +3657,10 @@
OPENSSL_EXPORT int SSL_set_tlsext_use_srtp(SSL *ssl, const char *profiles);
/* SSL_get_current_compression returns NULL. */
-OPENSSL_EXPORT const COMP_METHOD *SSL_get_current_compression(SSL *s);
+OPENSSL_EXPORT const COMP_METHOD *SSL_get_current_compression(SSL *ssl);
/* SSL_get_current_expansion returns NULL. */
-OPENSSL_EXPORT const COMP_METHOD *SSL_get_current_expansion(SSL *s);
+OPENSSL_EXPORT const COMP_METHOD *SSL_get_current_expansion(SSL *ssl);
/* SSL_get_server_tmp_key returns zero. */
OPENSSL_EXPORT int *SSL_get_server_tmp_key(SSL *ssl, EVP_PKEY **out_key);
@@ -3680,11 +3673,11 @@
/* SSL_CTX_set_tmp_dh_callback does nothing. */
OPENSSL_EXPORT void SSL_CTX_set_tmp_dh_callback(
- SSL_CTX *ctx, DH *(*callback)(SSL *ssl, int is_export, int keylength));
+ SSL_CTX *ctx, DH *(*cb)(SSL *ssl, int is_export, int keylength));
/* SSL_set_tmp_dh_callback does nothing. */
OPENSSL_EXPORT void SSL_set_tmp_dh_callback(SSL *ssl,
- DH *(*dh)(SSL *ssl, int is_export,
+ DH *(*cb)(SSL *ssl, int is_export,
int keylength));
@@ -3784,8 +3777,7 @@
* this function is confusing. This callback may not be registered concurrently
* with |SSL_CTX_set_cert_cb| or |SSL_set_cert_cb|. */
OPENSSL_EXPORT void SSL_CTX_set_client_cert_cb(
- SSL_CTX *ctx,
- int (*client_cert_cb)(SSL *ssl, X509 **out_x509, EVP_PKEY **out_pkey));
+ SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **out_x509, EVP_PKEY **out_pkey));
#define SSL_NOTHING 1
#define SSL_WRITING 2
@@ -4368,7 +4360,7 @@
* in: points to the client's list of supported protocols in
* wire-format.
* inlen: the length of |in|. */
- int (*alpn_select_cb)(SSL *s, const uint8_t **out, uint8_t *out_len,
+ int (*alpn_select_cb)(SSL *ssl, const uint8_t **out, uint8_t *out_len,
const uint8_t *in, unsigned in_len, void *arg);
void *alpn_select_cb_arg;
diff --git a/ssl/internal.h b/ssl/internal.h
index fe73d1e..a9fe951 100644
--- a/ssl/internal.h
+++ b/ssl/internal.h
@@ -716,7 +716,7 @@
enum ssl_private_key_result_t ssl_private_key_sign(
SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len, size_t max_out,
- uint16_t signature_algorithm, const uint8_t *in, size_t in_len);
+ uint16_t sigalg, const uint8_t *in, size_t in_len);
enum ssl_private_key_result_t ssl_private_key_decrypt(
SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len, size_t max_out,
@@ -728,11 +728,10 @@
uint16_t sigalg);
/* ssl_public_key_verify verifies that the |signature| is valid for the public
- * key |pkey| and input |in|, using the |signature_algorithm| specified. */
-int ssl_public_key_verify(
- SSL *ssl, const uint8_t *signature, size_t signature_len,
- uint16_t signature_algorithm, EVP_PKEY *pkey,
- const uint8_t *in, size_t in_len);
+ * key |pkey| and input |in|, using the signature algorithm |sigalg|. */
+int ssl_public_key_verify(SSL *ssl, const uint8_t *signature,
+ size_t signature_len, uint16_t sigalg, EVP_PKEY *pkey,
+ const uint8_t *in, size_t in_len);
/* Custom extensions */
@@ -2030,8 +2029,8 @@
CERT *ssl_cert_new(const SSL_X509_METHOD *x509_method);
CERT *ssl_cert_dup(CERT *cert);
-void ssl_cert_clear_certs(CERT *c);
-void ssl_cert_free(CERT *c);
+void ssl_cert_clear_certs(CERT *cert);
+void ssl_cert_free(CERT *cert);
int ssl_set_cert(CERT *cert, UniquePtr<CRYPTO_BUFFER> buffer);
int ssl_is_key_type_supported(int key_type);
/* ssl_compare_public_and_private_key returns one if |pubkey| is the public
diff --git a/ssl/ssl_cert.cc b/ssl/ssl_cert.cc
index deef3da..76af31e 100644
--- a/ssl/ssl_cert.cc
+++ b/ssl/ssl_cert.cc
@@ -222,24 +222,24 @@
cert->key_method = NULL;
}
-void ssl_cert_free(CERT *c) {
- if (c == NULL) {
+void ssl_cert_free(CERT *cert) {
+ if (cert == NULL) {
return;
}
- ssl_cert_clear_certs(c);
- c->x509_method->cert_free(c);
- OPENSSL_free(c->sigalgs);
- CRYPTO_BUFFER_free(c->signed_cert_timestamp_list);
- CRYPTO_BUFFER_free(c->ocsp_response);
+ ssl_cert_clear_certs(cert);
+ cert->x509_method->cert_free(cert);
+ OPENSSL_free(cert->sigalgs);
+ CRYPTO_BUFFER_free(cert->signed_cert_timestamp_list);
+ CRYPTO_BUFFER_free(cert->ocsp_response);
- OPENSSL_free(c);
+ OPENSSL_free(cert);
}
-static void ssl_cert_set_cert_cb(CERT *c, int (*cb)(SSL *ssl, void *arg),
+static void ssl_cert_set_cert_cb(CERT *cert, int (*cb)(SSL *ssl, void *arg),
void *arg) {
- c->cert_cb = cb;
- c->cert_cb_arg = arg;
+ cert->cert_cb = cb;
+ cert->cert_cb_arg = arg;
}
enum leaf_cert_and_privkey_result_t {
diff --git a/ssl/ssl_lib.cc b/ssl/ssl_lib.cc
index 8e7bd88..6611dd2 100644
--- a/ssl/ssl_lib.cc
+++ b/ssl/ssl_lib.cc
@@ -2148,8 +2148,8 @@
return index;
}
-int SSL_set_ex_data(SSL *ssl, int idx, void *arg) {
- return CRYPTO_set_ex_data(&ssl->ex_data, idx, arg);
+int SSL_set_ex_data(SSL *ssl, int idx, void *data) {
+ return CRYPTO_set_ex_data(&ssl->ex_data, idx, data);
}
void *SSL_get_ex_data(const SSL *ssl, int idx) {
@@ -2167,8 +2167,8 @@
return index;
}
-int SSL_CTX_set_ex_data(SSL_CTX *ctx, int idx, void *arg) {
- return CRYPTO_set_ex_data(&ctx->ex_data, idx, arg);
+int SSL_CTX_set_ex_data(SSL_CTX *ctx, int idx, void *data) {
+ return CRYPTO_set_ex_data(&ctx->ex_data, idx, data);
}
void *SSL_CTX_get_ex_data(const SSL_CTX *ctx, int idx) {
@@ -2179,21 +2179,17 @@
void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
RSA *(*cb)(SSL *ssl, int is_export,
- int keylength)) {
-}
+ int keylength)) {}
void SSL_set_tmp_rsa_callback(SSL *ssl, RSA *(*cb)(SSL *ssl, int is_export,
- int keylength)) {
-}
+ int keylength)) {}
void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
- DH *(*callback)(SSL *ssl, int is_export,
- int keylength)) {
-}
+ DH *(*cb)(SSL *ssl, int is_export,
+ int keylength)) {}
-void SSL_set_tmp_dh_callback(SSL *ssl, DH *(*callback)(SSL *ssl, int is_export,
- int keylength)) {
-}
+void SSL_set_tmp_dh_callback(SSL *ssl, DH *(*cb)(SSL *ssl, int is_export,
+ int keylength)) {}
static int use_psk_identity_hint(char **out, const char *identity_hint) {
if (identity_hint != NULL && strlen(identity_hint) > PSK_MAX_IDENTITY_LEN) {
diff --git a/ssl/ssl_session.cc b/ssl/ssl_session.cc
index a680471..1830723 100644
--- a/ssl/ssl_session.cc
+++ b/ssl/ssl_session.cc
@@ -911,7 +911,7 @@
return 0;
}
- assert(sizeof(session->sid_ctx) < 256);
+ static_assert(sizeof(session->sid_ctx) < 256, "sid_ctx_len does not fit");
session->sid_ctx_length = (uint8_t)sid_ctx_len;
OPENSSL_memcpy(session->sid_ctx, sid_ctx, sid_ctx_len);
diff --git a/tool/rand.cc b/tool/rand.cc
index b442e0d..6519a0d 100644
--- a/tool/rand.cc
+++ b/tool/rand.cc
@@ -42,7 +42,7 @@
std::vector<std::string> args_copy(args);
const std::string &last_arg = args.back();
- if (last_arg.size() > 0 && last_arg[0] != '-') {
+ if (!last_arg.empty() && last_arg[0] != '-') {
char *endptr;
unsigned long long num = strtoull(last_arg.c_str(), &endptr, 10);
if (*endptr == 0) {