mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix clang-tidy bugprone-multi-level-implicit-pointer-conversion warnings
This commit is contained in:
parent
9e83759e83
commit
d0bbc61bd4
3 changed files with 13 additions and 3 deletions
|
@ -5,4 +5,5 @@ Checks: [-*,
|
|||
bugprone-incorrect-division,
|
||||
bugprone-incorrect-roundings,
|
||||
bugprone-macro-parentheses,
|
||||
bugprone-multi-level-implicit-pointer-conversion,
|
||||
]
|
||||
|
|
|
@ -69,7 +69,12 @@ std::list<std::tuple<IPPrefix, void*>> 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<void*>(list));
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<void*>(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<void*>(filter->fields), sizeof(threading::Field*) * (filter->num_fields + 1));
|
||||
|
||||
if ( ! tmp ) {
|
||||
reporter->Error("out of memory in add_filter");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue