Skip to content

Commit

Permalink
Assert that each error-info-list starts with correct value (#978)
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm authored Feb 2, 2023
1 parent 3eca3cd commit 4a44071
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion source/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,20 @@ void aws_register_error_info(const struct aws_error_info_list *error_info) {
}

#if DEBUG_BUILD
/* Assert that first error has the right value */
const int expected_first_code = slot_index << AWS_ERROR_ENUM_STRIDE_BITS;
if (error_info->error_list[0].error_code != expected_first_code) {
fprintf(
stderr,
"Missing info: First error in list should be %d, not %d (%s)\n",
expected_first_code,
error_info->error_list[0].error_code,
error_info->error_list[0].literal_name);
AWS_FATAL_ASSERT(0);
}

/* Assert that error info entries are in the right order. */
for (int i = 1; i < error_info->count; ++i) {
for (int i = 0; i < error_info->count; ++i) {
const int expected_code = min_range + i;
const struct aws_error_info *info = &error_info->error_list[i];
if (info->error_code != expected_code) {
Expand Down

0 comments on commit 4a44071

Please sign in to comment.