@@ -159,16 +159,32 @@ void aws_register_error_info(const struct aws_error_info_list *error_info) {
159
159
if (slot_index >= AWS_MAX_ERROR_SLOTS || slot_index < 0 ) {
160
160
/* This is an NDEBUG build apparently. Kill the process rather than
161
161
* corrupting heap. */
162
- fprintf (stderr , "Bad error slot index 0x%016x \n" , slot_index );
163
- abort ( );
162
+ fprintf (stderr , "Bad error slot index %d \n" , slot_index );
163
+ AWS_FATAL_ASSERT ( 0 );
164
164
}
165
165
166
+ #if DEBUG_BUILD
167
+ /* Assert that error info entries are in the right order. */
168
+ for (int i = 1 ; i < error_info -> count ; ++ i ) {
169
+ const int expected_code = min_range + i ;
170
+ const struct aws_error_info * info = & error_info -> error_list [i ];
171
+ if (info -> error_code != expected_code ) {
172
+ if (info -> error_code ) {
173
+ fprintf (stderr , "Error %s is at wrong index of error info list.\n" , info -> literal_name );
174
+ } else {
175
+ fprintf (stderr , "Error %d is missing from error info list.\n" , expected_code );
176
+ }
177
+ AWS_FATAL_ASSERT (0 );
178
+ }
179
+ }
180
+ #endif /* DEBUG_BUILD */
181
+
166
182
ERROR_SLOTS [slot_index ] = error_info ;
167
183
}
168
184
169
185
static int8_t s_error_strings_loaded = 0 ;
170
186
171
- #define AWS_DEFINE_ERROR_INFO_COMMON (C , ES ) AWS_DEFINE_ERROR_INFO(C, ES, "libaws-c-common")
187
+ #define AWS_DEFINE_ERROR_INFO_COMMON (C , ES ) [(C)-0x0000] = AWS_DEFINE_ERROR_INFO(C, ES, "libaws-c-common")
172
188
173
189
/* clang-format off */
174
190
static struct aws_error_info errors [] = {
0 commit comments