Skip to content

Commit

Permalink
style: fix declarations without initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
jmayclin committed Feb 5, 2024
1 parent 6c7cdc8 commit 8ba2931
Show file tree
Hide file tree
Showing 208 changed files with 1,403 additions and 1,403 deletions.
4 changes: 2 additions & 2 deletions bin/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ int s2n_set_common_server_config(int max_early_data, struct s2n_config *config,

if (conn_settings.session_ticket || conn_settings.session_cache) {
/* Key initialization */
uint8_t *st_key;
uint32_t st_key_length;
uint8_t *st_key = NULL;
uint32_t st_key_length = 0;

if (session_ticket_key_file_path) {
int fd = open(session_ticket_key_file_path, O_RDONLY);
Expand Down
10 changes: 5 additions & 5 deletions bin/echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ int early_data_send(struct s2n_connection *conn, uint8_t *data, uint32_t len)

int print_connection_info(struct s2n_connection *conn)
{
int client_hello_version;
int client_protocol_version;
int server_protocol_version;
int actual_protocol_version;
int client_hello_version = 0;
int client_protocol_version = 0;
int server_protocol_version = 0;
int actual_protocol_version = 0;

if ((client_hello_version = s2n_connection_get_client_hello_version(conn)) < 0) {
fprintf(stderr, "Could not get client hello version\n");
Expand Down Expand Up @@ -179,7 +179,7 @@ int print_connection_info(struct s2n_connection *conn)
printf("KEM: %s\n", s2n_connection_get_kem_name(conn));
printf("KEM Group: %s\n", s2n_connection_get_kem_group_name(conn));

uint32_t length;
uint32_t length = 0;
const uint8_t *status = s2n_connection_get_ocsp_response(conn, &length);
if (status && length > 0) {
printf("OCSP response received, length %u\n", length);
Expand Down
4 changes: 2 additions & 2 deletions bin/s2nc.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ static void setup_s2n_config(struct s2n_config *config, const char *cipher_prefs

int main(int argc, char *const *argv)
{
struct addrinfo hints, *ai_list, *ai;
int r, sockfd = 0;
struct addrinfo hints, *ai_list = NULL, *ai = NULL;
int r = 0, sockfd = 0;
bool session_ticket_recv = 0;
/* Optional args */
const char *alpn_protocols = NULL;
Expand Down
6 changes: 3 additions & 3 deletions bin/s2nd.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ int handle_connection(int fd, struct s2n_config *config, struct conn_settings se

int main(int argc, char *const *argv)
{
struct addrinfo hints, *ai;
int r, sockfd = 0;
struct addrinfo hints, *ai = NULL;
int r = 0, sockfd = 0;

/* required args */
const char *host = NULL;
Expand Down Expand Up @@ -629,7 +629,7 @@ int main(int argc, char *const *argv)
"Failed to set key log callback");
}

int fd;
int fd = 0;
while ((fd = accept(sockfd, ai->ai_addr, &ai->ai_addrlen)) > 0) {
if (non_blocking) {
int flags = fcntl(sockfd, F_GETFL, 0);
Expand Down
6 changes: 3 additions & 3 deletions crypto/s2n_dhe.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
static const BIGNUM *s2n_get_Ys_dh_param(struct s2n_dh_params *dh_params)
{
const BIGNUM *Ys;
const BIGNUM *Ys = NULL;

/* DH made opaque in Openssl 1.1.0 */
#if S2N_OPENSSL_VERSION_AT_LEAST(1, 1, 0)
Expand All @@ -48,7 +48,7 @@ static const BIGNUM *s2n_get_Ys_dh_param(struct s2n_dh_params *dh_params)

static const BIGNUM *s2n_get_p_dh_param(struct s2n_dh_params *dh_params)
{
const BIGNUM *p;
const BIGNUM *p = NULL;
#if S2N_OPENSSL_VERSION_AT_LEAST(1, 1, 0)
DH_get0_pqg(dh_params->dh, &p, NULL, NULL);
#else
Expand All @@ -60,7 +60,7 @@ static const BIGNUM *s2n_get_p_dh_param(struct s2n_dh_params *dh_params)

static const BIGNUM *s2n_get_g_dh_param(struct s2n_dh_params *dh_params)
{
const BIGNUM *g;
const BIGNUM *g = NULL;
#if S2N_OPENSSL_VERSION_AT_LEAST(1, 1, 0)
DH_get0_pqg(dh_params->dh, NULL, NULL, &g);
#else
Expand Down
10 changes: 5 additions & 5 deletions crypto/s2n_ecc_evp.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static int s2n_ecc_evp_compute_shared_secret(EVP_PKEY *own_key, EVP_PKEY *peer_p
POSIX_GUARD_OSSL(EC_KEY_check_key(ec_key), S2N_ERR_ECDHE_SHARED_SECRET);
}

size_t shared_secret_size;
size_t shared_secret_size = 0;

DEFER_CLEANUP(EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(own_key, NULL), EVP_PKEY_CTX_free_pointer);
S2N_ERROR_IF(ctx == NULL, S2N_ERR_ECDHE_SHARED_SECRET);
Expand Down Expand Up @@ -233,7 +233,7 @@ int s2n_ecc_evp_compute_shared_secret_as_server(struct s2n_ecc_evp_params *ecc_e
POSIX_ENSURE_REF(ecc_evp_params->evp_pkey);
POSIX_ENSURE_REF(Yc_in);

uint8_t client_public_len;
uint8_t client_public_len = 0;
struct s2n_blob client_public_blob = { 0 };

DEFER_CLEANUP(EVP_PKEY *peer_key = EVP_PKEY_new(), EVP_PKEY_free_pointer);
Expand Down Expand Up @@ -345,8 +345,8 @@ int s2n_ecc_evp_read_params(struct s2n_stuffer *in, struct s2n_blob *data_to_ver
struct s2n_ecdhe_raw_server_params *raw_server_ecc_params)
{
POSIX_ENSURE_REF(in);
uint8_t curve_type;
uint8_t point_length;
uint8_t curve_type = 0;
uint8_t point_length = 0;

/* Remember where we started reading the data */
data_to_verify->data = s2n_stuffer_raw_read(in, 0);
Expand Down Expand Up @@ -507,7 +507,7 @@ int s2n_ecc_evp_find_supported_curve(struct s2n_connection *conn, struct s2n_blo
for (size_t i = 0; i < ecc_prefs->count; i++) {
const struct s2n_ecc_named_curve *supported_curve = ecc_prefs->ecc_curves[i];
for (uint32_t j = 0; j < iana_ids->size / 2; j++) {
uint16_t iana_id;
uint16_t iana_id = 0;
POSIX_GUARD(s2n_stuffer_read_uint16(&iana_ids_in, &iana_id));
if (supported_curve->iana_id == iana_id) {
*found = supported_curve;
Expand Down
2 changes: 1 addition & 1 deletion crypto/s2n_ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static int s2n_ecdsa_verify(const struct s2n_pkey *pub, s2n_signature_algorithm
const s2n_ecdsa_public_key *key = &pub->key.ecdsa_key;
POSIX_ENSURE_REF(key->ec_key);

uint8_t digest_length;
uint8_t digest_length = 0;
POSIX_GUARD(s2n_hash_digest_size(digest->alg, &digest_length));
POSIX_ENSURE_LTE(digest_length, S2N_MAX_DIGEST_LEN);

Expand Down
2 changes: 1 addition & 1 deletion crypto/s2n_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ int s2n_hash_const_time_get_currently_in_hash_block(struct s2n_hash_state *state
POSIX_PRECONDITION(s2n_hash_state_validate(state));
POSIX_ENSURE(S2N_MEM_IS_WRITABLE_CHECK(out, sizeof(*out)), S2N_ERR_PRECONDITION_VIOLATION);
POSIX_ENSURE(state->is_ready_for_input, S2N_ERR_HASH_NOT_READY);
uint64_t hash_block_size;
uint64_t hash_block_size = 0;
POSIX_GUARD(s2n_hash_block_size(state->alg, &hash_block_size));

/* Requires that hash_block_size is a power of 2. This is true for all hashes we currently support
Expand Down
2 changes: 1 addition & 1 deletion crypto/s2n_hkdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static int s2n_custom_hkdf_expand(struct s2n_hmac_state *hmac, s2n_hmac_algorith
POSIX_ENSURE(total_rounds <= MAX_HKDF_ROUNDS, S2N_ERR_HKDF_OUTPUT_SIZE);

for (uint32_t curr_round = 1; curr_round <= total_rounds; curr_round++) {
uint32_t cat_len;
uint32_t cat_len = 0;
POSIX_GUARD(s2n_hmac_init(hmac, alg, pseudo_rand_key->data, pseudo_rand_key->size));
if (curr_round != 1) {
POSIX_GUARD(s2n_hmac_update(hmac, prev, hash_len));
Expand Down
2 changes: 1 addition & 1 deletion crypto/s2n_hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ int s2n_hmac_reset(struct s2n_hmac_state *state)
POSIX_ENSURE(state->hash_block_size != 0, S2N_ERR_PRECONDITION_VIOLATION);
POSIX_GUARD(s2n_hash_copy(&state->inner, &state->inner_just_key));

uint64_t bytes_in_hash;
uint64_t bytes_in_hash = 0;
POSIX_GUARD(s2n_hash_get_currently_in_hash_total(&state->inner, &bytes_in_hash));
bytes_in_hash %= state->hash_block_size;
POSIX_ENSURE(bytes_in_hash <= UINT32_MAX, S2N_ERR_INTEGER_OVERFLOW);
Expand Down
6 changes: 3 additions & 3 deletions crypto/s2n_rsa_signing.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ int s2n_rsa_pkcs1v15_sign(const struct s2n_pkey *priv, struct s2n_hash_state *di

int s2n_rsa_pkcs1v15_verify(const struct s2n_pkey *pub, struct s2n_hash_state *digest, struct s2n_blob *signature)
{
uint8_t digest_length;
int digest_NID_type;
uint8_t digest_length = 0;
int digest_NID_type = 0;
POSIX_GUARD(s2n_hash_digest_size(digest->alg, &digest_length));
POSIX_GUARD(s2n_hash_NID_type(digest->alg, &digest_NID_type));
POSIX_ENSURE_LTE(digest_length, S2N_MAX_DIGEST_LEN);
Expand Down Expand Up @@ -186,7 +186,7 @@ int s2n_rsa_pss_verify(const struct s2n_pkey *pub, struct s2n_hash_state *digest
{
POSIX_ENSURE_REF(pub);

uint8_t digest_length;
uint8_t digest_length = 0;
uint8_t digest_data[S2N_MAX_DIGEST_LEN];
POSIX_GUARD(s2n_hash_digest_size(digest->alg, &digest_length));
POSIX_GUARD(s2n_hash_digest(digest, digest_data, digest_length));
Expand Down
6 changes: 3 additions & 3 deletions tests/testlib/s2n_connection_test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ int s2n_fd_set_non_blocking(int fd)

static int buffer_read(void *io_context, uint8_t *buf, uint32_t len)
{
struct s2n_stuffer *in_buf;
int n_read, n_avail;
struct s2n_stuffer *in_buf = NULL;
int n_read = 0, n_avail = 0;

if (buf == NULL) {
return 0;
Expand All @@ -64,7 +64,7 @@ static int buffer_read(void *io_context, uint8_t *buf, uint32_t len)

static int buffer_write(void *io_context, const uint8_t *buf, uint32_t len)
{
struct s2n_stuffer *out;
struct s2n_stuffer *out = NULL;

if (buf == NULL) {
return 0;
Expand Down
10 changes: 5 additions & 5 deletions tests/testlib/s2n_stuffer_hex.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int s2n_stuffer_read_hex(struct s2n_stuffer *stuffer, struct s2n_stuffer *out, u
POSIX_ENSURE_GTE(s2n_stuffer_space_remaining(out), n);

for (size_t i = 0; i < n; i++) {
uint8_t c;
uint8_t c = 0;
POSIX_GUARD(s2n_stuffer_read_uint8_hex(stuffer, &c));
POSIX_GUARD(s2n_stuffer_write_uint8(out, c));
}
Expand All @@ -72,7 +72,7 @@ int s2n_stuffer_write_hex(struct s2n_stuffer *stuffer, struct s2n_stuffer *in, u
POSIX_ENSURE_GTE(s2n_stuffer_space_remaining(stuffer), n * 2);

for (size_t i = 0; i < n; i++) {
uint8_t c;
uint8_t c = 0;
POSIX_GUARD(s2n_stuffer_read_uint8(in, &c));
POSIX_GUARD(s2n_stuffer_write_uint8_hex(stuffer, c));
}
Expand All @@ -87,7 +87,7 @@ int s2n_stuffer_read_uint64_hex(struct s2n_stuffer *stuffer, uint64_t *u)

int s2n_stuffer_read_uint32_hex(struct s2n_stuffer *stuffer, uint32_t *u)
{
uint64_t u64;
uint64_t u64 = 0;

POSIX_GUARD(s2n_stuffer_read_n_bits_hex(stuffer, 32, &u64));

Expand All @@ -98,7 +98,7 @@ int s2n_stuffer_read_uint32_hex(struct s2n_stuffer *stuffer, uint32_t *u)

int s2n_stuffer_read_uint16_hex(struct s2n_stuffer *stuffer, uint16_t *u)
{
uint64_t u64;
uint64_t u64 = 0;

POSIX_GUARD(s2n_stuffer_read_n_bits_hex(stuffer, 16, &u64));

Expand All @@ -109,7 +109,7 @@ int s2n_stuffer_read_uint16_hex(struct s2n_stuffer *stuffer, uint16_t *u)

int s2n_stuffer_read_uint8_hex(struct s2n_stuffer *stuffer, uint8_t *u)
{
uint64_t u64;
uint64_t u64 = 0;

POSIX_GUARD(s2n_stuffer_read_n_bits_hex(stuffer, 8, &u64));

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/s2n_3des_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

int main(int argc, char **argv)
{
struct s2n_connection *conn;
struct s2n_connection *conn = NULL;
uint8_t mac_key[] = "sample mac key";
uint8_t des3_key[] = "12345678901234567890123";
struct s2n_blob des3 = { 0 };
Expand Down Expand Up @@ -61,7 +61,7 @@ int main(int argc, char **argv)
for (int i = 0; i <= S2N_DEFAULT_FRAGMENT_LENGTH + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
int bytes_written;
int bytes_written = 0;

EXPECT_SUCCESS(s2n_stuffer_wipe(&conn->out));

Expand Down Expand Up @@ -96,8 +96,8 @@ int main(int argc, char **argv)
EXPECT_SUCCESS(s2n_stuffer_copy(&conn->out, &conn->in, s2n_stuffer_data_available(&conn->out)));

/* Let's decrypt it */
uint8_t content_type;
uint16_t fragment_length;
uint8_t content_type = 0;
uint16_t fragment_length = 0;
EXPECT_SUCCESS(s2n_record_header_parse(conn, &content_type, &fragment_length));
EXPECT_SUCCESS(s2n_record_parse(conn));
EXPECT_EQUAL(content_type, TLS_APPLICATION_DATA);
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/s2n_aead_aes_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int setup_server_keys(struct s2n_connection *server_conn, struct s2n_blob

int main(int argc, char **argv)
{
struct s2n_connection *conn;
struct s2n_connection *conn = NULL;
uint8_t random_data[S2N_SMALL_FRAGMENT_LENGTH + 1];
uint8_t aes128_key[] = "123456789012345";
uint8_t aes256_key[] = "1234567890123456789012345678901";
Expand Down Expand Up @@ -76,7 +76,7 @@ int main(int argc, char **argv)
for (size_t i = 0; i <= max_fragment + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
int bytes_written;
int bytes_written = 0;

/* TLS packet on the wire using AES-GCM:
* https://tools.ietf.org/html/rfc5246#section-6.2.3.3
Expand Down Expand Up @@ -135,8 +135,8 @@ int main(int argc, char **argv)
EXPECT_SUCCESS(s2n_stuffer_copy(&conn->out, &conn->in, s2n_stuffer_data_available(&conn->out)));

/* Let's decrypt it */
uint8_t content_type;
uint16_t fragment_length;
uint8_t content_type = 0;
uint16_t fragment_length = 0;
EXPECT_SUCCESS(s2n_record_header_parse(conn, &content_type, &fragment_length));
EXPECT_SUCCESS(s2n_record_parse(conn));
EXPECT_EQUAL(content_type, TLS_APPLICATION_DATA);
Expand Down Expand Up @@ -274,7 +274,7 @@ int main(int argc, char **argv)
for (size_t i = 0; i <= max_fragment + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
int bytes_written;
int bytes_written = 0;

EXPECT_SUCCESS(s2n_connection_wipe(conn));
/* Set prefer low latency for S2N_SMALL_FRAGMENT_LENGTH for */
Expand Down Expand Up @@ -323,8 +323,8 @@ int main(int argc, char **argv)
EXPECT_SUCCESS(s2n_stuffer_copy(&conn->out, &conn->in, s2n_stuffer_data_available(&conn->out)));

/* Let's decrypt it */
uint8_t content_type;
uint16_t fragment_length;
uint8_t content_type = 0;
uint16_t fragment_length = 0;
EXPECT_SUCCESS(s2n_record_header_parse(conn, &content_type, &fragment_length));
EXPECT_SUCCESS(s2n_record_parse(conn));
EXPECT_EQUAL(content_type, TLS_APPLICATION_DATA);
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/s2n_aead_chacha20_poly1305_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static int setup_server_keys(struct s2n_connection *server_conn, struct s2n_blob

int main(int argc, char **argv)
{
struct s2n_connection *conn;
struct s2n_connection *conn = NULL;
uint8_t random_data[S2N_SMALL_FRAGMENT_LENGTH + 1];
uint8_t chacha20_poly1305_key_data[] = "1234567890123456789012345678901";
struct s2n_blob chacha20_poly1305_key = { 0 };
Expand Down Expand Up @@ -79,7 +79,7 @@ int main(int argc, char **argv)
for (size_t i = 0; i <= max_fragment + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
int bytes_written;
int bytes_written = 0;

/* TLS packet on the wire using ChaCha20-Poly1305:
* https://tools.ietf.org/html/rfc5246#section-6.2.3.3
Expand Down Expand Up @@ -135,8 +135,8 @@ int main(int argc, char **argv)
EXPECT_SUCCESS(s2n_stuffer_copy(&conn->out, &conn->in, s2n_stuffer_data_available(&conn->out)));

/* Let's decrypt it */
uint8_t content_type;
uint16_t fragment_length;
uint8_t content_type = 0;
uint16_t fragment_length = 0;
EXPECT_SUCCESS(s2n_record_header_parse(conn, &content_type, &fragment_length));
EXPECT_SUCCESS(s2n_record_parse(conn));
EXPECT_EQUAL(content_type, TLS_APPLICATION_DATA);
Expand Down
Loading

0 comments on commit 8ba2931

Please sign in to comment.