diff --git a/.clang-tidy b/.clang-tidy index aafda51013..cfc4d35fc9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,4 +5,5 @@ Checks: [-*, bugprone-incorrect-division, bugprone-incorrect-roundings, bugprone-macro-parentheses, + bugprone-multi-level-implicit-pointer-conversion, ] diff --git a/src/PrefixTable.cc b/src/PrefixTable.cc index bc975c8fa4..a30dcc1568 100644 --- a/src/PrefixTable.cc +++ b/src/PrefixTable.cc @@ -69,7 +69,12 @@ std::list> PrefixTable::FindAll(const IPAddr& addr, out.emplace_back(PrefixToIPPrefix(list[i]->prefix), list[i]->data); Deref_Prefix(prefix); - free(list); + + // clang-tidy reports a bugprone-multi-level-implicit-pointer-conversion warning here + // because the double-pointer is implicitly converted to a void* for the call to + // free(). The double-pointer was calloc'd in patricia_search_all as an array of + // pointers, so it's safe to free. Explicitly cast it to void* to silence the warning. + free(static_cast(list)); return out; } diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 56f75dc485..89dcb1fa13 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -340,7 +340,9 @@ Manager::Filter::~Filter() { for ( int i = 0; i < num_fields; ++i ) delete fields[i]; - free(fields); + // Static cast this to void* to avoid a clang-tidy warning about converting from the + // double-pointer to void* + free(static_cast(fields)); Unref(path_val); Unref(config); @@ -811,7 +813,9 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, Tab // Alright, we want this field. filter->indices.push_back(new_indices); - void* tmp = realloc(filter->fields, sizeof(threading::Field*) * (filter->num_fields + 1)); + // Static cast this to void* to avoid a clang-tidy warning about converting from the + // double-pointer to void* + void* tmp = realloc(static_cast(filter->fields), sizeof(threading::Field*) * (filter->num_fields + 1)); if ( ! tmp ) { reporter->Error("out of memory in add_filter");