Skip to content

Commit

Permalink
satisfy some signed vs unsigned comparison warnings (#809)
Browse files Browse the repository at this point in the history
Co-authored-by: Lopez <[email protected]>
Co-authored-by: Michael Graeb <[email protected]>
Co-authored-by: Bret Ambrose <[email protected]>
Co-authored-by: Joseph Klix <[email protected]>
  • Loading branch information
5 people authored Apr 29, 2024
1 parent 24da21d commit 86a056c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions source/arch/intel/encoding_avx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ static inline bool decode(const unsigned char *in, unsigned char *out) {

size_t aws_common_private_base64_decode_sse41(const unsigned char *in, unsigned char *out, size_t len) {
if (len % 4) {
return (size_t)-1;
return SIZE_MAX;
}

size_t outlen = 0;
while (len > 32) {
if (!decode(in, out)) {
return (size_t)-1;
return SIZE_MAX;
}
len -= 32;
in += 32;
Expand Down Expand Up @@ -230,13 +230,13 @@ size_t aws_common_private_base64_decode_sse41(const unsigned char *in, unsigned
}

if (!decode(tmp_in, tmp_out)) {
return (size_t)-1;
return SIZE_MAX;
}

/* Check that there are no trailing ones bits */
for (size_t i = final_out; i < sizeof(tmp_out); i++) {
if (tmp_out[i]) {
return (size_t)-1;
return SIZE_MAX;
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static inline size_t aws_common_private_base64_decode_sse41(const unsigned char
(void)out;
(void)len;
AWS_ASSERT(false);
return (size_t)-1; /* unreachable */
return SIZE_MAX; /* unreachable */
}
static inline void aws_common_private_base64_encode_sse41(const unsigned char *in, unsigned char *out, size_t len) {
(void)in;
Expand Down Expand Up @@ -361,7 +361,7 @@ int aws_base64_decode(const struct aws_byte_cursor *AWS_RESTRICT to_decode, stru

if (aws_common_private_has_avx2()) {
size_t result = aws_common_private_base64_decode_sse41(to_decode->ptr, output->buffer, to_decode->len);
if (result == -1) {
if (result == SIZE_MAX) {
return aws_raise_error(AWS_ERROR_INVALID_BASE64_STR);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/atomics_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static int run_races(
int *participant_indexes = alloca(n_participants_local * sizeof(*participant_indexes));
struct aws_thread *threads = alloca(n_participants_local * sizeof(struct aws_thread));

*last_race = (size_t)-1;
*last_race = SIZE_MAX;
n_participants = n_participants_local;
done_racing = false;
aws_atomic_init_int(&last_race_index, 0);
Expand All @@ -293,7 +293,7 @@ static int run_races(
*last_race = n_races;
} else {
*last_race = (size_t)aws_atomic_load_int_explicit(&last_race_index, aws_memory_order_relaxed);
if (*last_race == (size_t)-1) {
if (*last_race == SIZE_MAX) {
/* We didn't even see the first race complete */
*last_race = 0;
}
Expand Down

0 comments on commit 86a056c

Please sign in to comment.