mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix variable shadowing issues reported by LGTM
This commit is contained in:
parent
59b40168fb
commit
2f2a265415
4 changed files with 26 additions and 26 deletions
|
@ -34,8 +34,8 @@ void CCL::Add(int sym)
|
|||
auto sym_p = static_cast<std::intptr_t>(sym);
|
||||
|
||||
// Check to see if the character is already in the ccl.
|
||||
for ( auto sym : *syms )
|
||||
if ( sym == sym_p )
|
||||
for ( auto sym_entry : *syms )
|
||||
if ( sym_entry == sym_p )
|
||||
return;
|
||||
|
||||
syms->push_back(sym_p);
|
||||
|
|
|
@ -187,14 +187,14 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
auto rv_i = rv->GetField(i).get();
|
||||
|
||||
Attributes* a = rt->FieldDecl(i)->attrs.get();
|
||||
bool optional = (a && a->Find(ATTR_OPTIONAL));
|
||||
bool optional_attr = (a && a->Find(ATTR_OPTIONAL));
|
||||
|
||||
if ( ! (rv_i || optional) )
|
||||
if ( ! (rv_i || optional_attr) )
|
||||
return nullptr;
|
||||
|
||||
if ( ! (kp = SingleValHash(type_check, kp,
|
||||
rt->GetFieldType(i).get(),
|
||||
rv_i, optional)) )
|
||||
rv_i, optional_attr)) )
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -292,9 +292,9 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
|||
kp1 = reinterpret_cast<char*>(kp+1);
|
||||
for ( int i = 0; i < lv->Length(); ++i )
|
||||
{
|
||||
Val* v = lv->Idx(i).get();
|
||||
if ( ! (kp1 = SingleValHash(type_check, kp1, v->GetType().get(), v,
|
||||
false)) )
|
||||
Val* entry_val = lv->Idx(i).get();
|
||||
if ( ! (kp1 = SingleValHash(type_check, kp1, entry_val->GetType().get(),
|
||||
entry_val, false)) )
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -515,11 +515,11 @@ int CompositeHash::SingleTypeKeySize(Type* bt, const Val* v,
|
|||
for ( int i = 0; i < num_fields; ++i )
|
||||
{
|
||||
Attributes* a = rt->FieldDecl(i)->attrs.get();
|
||||
bool optional = (a && a->Find(ATTR_OPTIONAL));
|
||||
bool optional_attr = (a && a->Find(ATTR_OPTIONAL));
|
||||
|
||||
sz = SingleTypeKeySize(rt->GetFieldType(i).get(),
|
||||
rv ? rv->GetField(i).get() : nullptr,
|
||||
type_check, sz, optional,
|
||||
type_check, sz, optional_attr,
|
||||
calc_static_size);
|
||||
if ( ! sz )
|
||||
return 0;
|
||||
|
|
30
src/Debug.cc
30
src/Debug.cc
|
@ -113,14 +113,14 @@ int debug_msg(const char* fmt, ...)
|
|||
|
||||
// Trace message output
|
||||
|
||||
FILE* TraceState::SetTraceFile(const char* filename)
|
||||
FILE* TraceState::SetTraceFile(const char* trace_filename)
|
||||
{
|
||||
FILE* newfile;
|
||||
|
||||
if ( util::streq(filename, "-") )
|
||||
if ( util::streq(trace_filename, "-") )
|
||||
newfile = stderr;
|
||||
else
|
||||
newfile = fopen(filename, "w");
|
||||
newfile = fopen(trace_filename, "w");
|
||||
|
||||
FILE* oldfile = trace_file;
|
||||
if ( newfile )
|
||||
|
@ -129,7 +129,7 @@ FILE* TraceState::SetTraceFile(const char* filename)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Unable to open trace file %s\n", filename);
|
||||
fprintf(stderr, "Unable to open trace file %s\n", trace_filename);
|
||||
trace_file = nullptr;
|
||||
}
|
||||
|
||||
|
@ -326,19 +326,19 @@ static void parse_function_name(vector<ParseLocationRec>& result,
|
|||
else
|
||||
{
|
||||
result.pop_back();
|
||||
ParseLocationRec plr;
|
||||
ParseLocationRec result_plr;
|
||||
|
||||
for ( unsigned int i = 0; i < bodies.size(); ++i )
|
||||
for ( const auto& body : bodies )
|
||||
{
|
||||
get_first_statement(bodies[i].stmts.get(), first, stmt_loc);
|
||||
get_first_statement(body.stmts.get(), first, stmt_loc);
|
||||
if ( ! first )
|
||||
continue;
|
||||
|
||||
plr.type = PLR_FUNCTION;
|
||||
plr.stmt = first;
|
||||
plr.filename = stmt_loc.filename;
|
||||
plr.line = stmt_loc.last_line;
|
||||
result.push_back(plr);
|
||||
result_plr.type = PLR_FUNCTION;
|
||||
result_plr.stmt = first;
|
||||
result_plr.filename = stmt_loc.filename;
|
||||
result_plr.line = stmt_loc.last_line;
|
||||
result.push_back(result_plr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -369,17 +369,17 @@ vector<ParseLocationRec> parse_location_string(const string& s)
|
|||
parse_function_name(result, plr, s);
|
||||
else
|
||||
{ // file:line
|
||||
string filename = s.substr(0, pos_colon);
|
||||
string policy_filename = s.substr(0, pos_colon);
|
||||
string line_string = s.substr(pos_colon + 1, s.length() - pos_colon);
|
||||
|
||||
if ( ! sscanf(line_string.c_str(), "%d", &plr.line) )
|
||||
plr.type = PLR_UNKNOWN;
|
||||
|
||||
string path(util::find_script_file(filename, util::zeek_path()));
|
||||
string path(util::find_script_file(policy_filename, util::zeek_path()));
|
||||
|
||||
if ( path.empty() )
|
||||
{
|
||||
debug_msg("No such policy file: %s.\n", filename.c_str());
|
||||
debug_msg("No such policy file: %s.\n", policy_filename.c_str());
|
||||
plr.type = PLR_UNKNOWN;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
TraceState() { dbgtrace = false; trace_file = stderr; }
|
||||
|
||||
// Returns previous filename.
|
||||
FILE* SetTraceFile(const char* filename);
|
||||
FILE* SetTraceFile(const char* trace_filename);
|
||||
|
||||
bool DoTrace() const { return dbgtrace; }
|
||||
void TraceOn();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue