When assertions is disable, there is a warning about unused check_index_range function

Make the check for a valid index range a macro, so the compiler doesn't
whine if it's not used, but it's available if it *is* used.
This commit is contained in:
Alexis La Goutte 2014-06-16 18:52:11 +02:00
parent 7f6ddd0f2e
commit c9b6371977
1 changed files with 3 additions and 5 deletions

View File

@ -993,10 +993,8 @@ static void clear_refset(nghttp2_hd_context *context)
} }
} }
static int check_index_range(nghttp2_hd_context *context, size_t idx) #define INDEX_RANGE_VALID(context, idx) \
{ ((idx) < (context)->hd_table.len + STATIC_TABLE_LENGTH)
return idx < context->hd_table.len + STATIC_TABLE_LENGTH;
}
static size_t get_max_index(nghttp2_hd_context *context) static size_t get_max_index(nghttp2_hd_context *context)
{ {
@ -1006,7 +1004,7 @@ static size_t get_max_index(nghttp2_hd_context *context)
nghttp2_hd_entry* nghttp2_hd_table_get(nghttp2_hd_context *context, nghttp2_hd_entry* nghttp2_hd_table_get(nghttp2_hd_context *context,
size_t idx) size_t idx)
{ {
assert(check_index_range(context, idx)); assert(INDEX_RANGE_VALID(context, idx));
if(idx < context->hd_table.len) { if(idx < context->hd_table.len) {
return hd_ringbuf_get(&context->hd_table, idx); return hd_ringbuf_get(&context->hd_table, idx);
} else { } else {