Skip to content

Commit

Permalink
Merge pull request #9 from awslabs/asserts-for-everyone
Browse files Browse the repository at this point in the history
assert -> AWS_ASSERT, removed assert.h includes, updated clang-tidy
  • Loading branch information
Justin Boswell authored May 13, 2019
2 parents a31832e + b4f259a commit 3c10c22
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ CheckOptions:
- key: google-runtime-int.TypeSufix
value: '_t'
- key: fuchsia-restrict-system-includes.Includes
value: '*,-stdint.h,-stdbool.h'
value: '*,-stdint.h,-stdbool.h,-assert.h'

...
4 changes: 2 additions & 2 deletions source/bcrypt/bcrypt_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct bcrypt_hash_handle {
static void s_load_sha256_alg_handle(void) {
/* this function is incredibly slow, LET IT LEAK*/
BCryptOpenAlgorithmProvider(&s_sha256_alg, BCRYPT_SHA256_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
assert(s_sha256_alg);
AWS_ASSERT(s_sha256_alg);
DWORD result_length = 0;
BCryptGetProperty(
s_sha256_alg, BCRYPT_OBJECT_LENGTH, (PBYTE)&s_sha256_obj_len, sizeof(s_sha256_obj_len), &result_length, 0);
Expand All @@ -66,7 +66,7 @@ static void s_load_sha256_alg_handle(void) {
static void s_load_md5_alg_handle(void) {
/* this function is incredibly slow, LET IT LEAK*/
BCryptOpenAlgorithmProvider(&s_md5_alg, BCRYPT_MD5_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
assert(s_md5_alg);
AWS_ASSERT(s_md5_alg);
DWORD result_length = 0;
BCryptGetProperty(s_md5_alg, BCRYPT_OBJECT_LENGTH, (PBYTE)&s_md5_obj_len, sizeof(s_md5_obj_len), &result_length, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion source/bcrypt/bcrypt_hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void s_load_alg_handle(void) {
/* this function is incredibly slow, LET IT LEAK*/
BCryptOpenAlgorithmProvider(
&s_sha256_hmac_alg, BCRYPT_SHA256_ALGORITHM, MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG);
assert(s_sha256_hmac_alg);
AWS_ASSERT(s_sha256_hmac_alg);
DWORD result_length = 0;
BCryptGetProperty(
s_sha256_hmac_alg,
Expand Down
2 changes: 1 addition & 1 deletion source/commoncrypto/commoncrypto_hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct cc_hmac {
};

struct aws_hmac *aws_sha256_hmac_default_new(struct aws_allocator *allocator, const struct aws_byte_cursor *secret) {
assert(secret->ptr);
AWS_ASSERT(secret->ptr);

struct cc_hmac *cc_hmac = aws_mem_acquire(allocator, sizeof(struct cc_hmac));

Expand Down
2 changes: 1 addition & 1 deletion source/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int aws_hash_finalize(struct aws_hash *hash, struct aws_byte_buf *output, size_t
}

uint8_t tmp_output[128] = {0};
assert(sizeof(tmp_output) >= hash->digest_size);
AWS_ASSERT(sizeof(tmp_output) >= hash->digest_size);

struct aws_byte_buf tmp_out_buf = aws_byte_buf_from_array(tmp_output, sizeof(tmp_output));
tmp_out_buf.len = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int aws_hmac_finalize(struct aws_hmac *hmac, struct aws_byte_buf *output, size_t
}

uint8_t tmp_output[128] = {0};
assert(sizeof(tmp_output) >= hmac->digest_size);
AWS_ASSERT(sizeof(tmp_output) >= hmac->digest_size);

struct aws_byte_buf tmp_out_buf = aws_byte_buf_from_array(tmp_output, sizeof(tmp_output));
tmp_out_buf.len = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/opensslcrypto/opensslcrypto_hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static struct aws_hmac_vtable s_sha256_hmac_vtable = {
};

struct aws_hmac *aws_sha256_hmac_default_new(struct aws_allocator *allocator, const struct aws_byte_cursor *secret) {
assert(secret->ptr);
AWS_ASSERT(secret->ptr);

struct aws_hmac *hmac = aws_mem_acquire(allocator, sizeof(struct aws_hmac));

Expand Down

0 comments on commit 3c10c22

Please sign in to comment.