mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
binpac: Fix LGTM findings
This commit is contained in:
parent
5d75f8ed6c
commit
f365c253a7
10 changed files with 30 additions and 23 deletions
|
@ -17,6 +17,7 @@ void Attr::init()
|
|||
{
|
||||
expr_ = 0;
|
||||
seqend_ = 0;
|
||||
delete_expr_ = false;
|
||||
}
|
||||
|
||||
Attr::Attr(AttrType type)
|
||||
|
@ -40,6 +41,7 @@ Attr::Attr(AttrType type, ExprList *exprlist)
|
|||
type_ = type;
|
||||
init();
|
||||
expr_ = new Expr(exprlist);
|
||||
delete_expr_ = true;
|
||||
}
|
||||
|
||||
Attr::Attr(AttrType type, SeqEnd *seqend)
|
||||
|
@ -50,6 +52,12 @@ Attr::Attr(AttrType type, SeqEnd *seqend)
|
|||
seqend_ = seqend;
|
||||
}
|
||||
|
||||
Attr::~Attr()
|
||||
{
|
||||
if ( delete_expr_ )
|
||||
delete expr_;
|
||||
}
|
||||
|
||||
LetAttr::LetAttr(FieldList *letfields)
|
||||
: Attr(ATTR_LET)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,8 @@ public:
|
|||
Attr(AttrType type, ExprList *exprlist);
|
||||
Attr(AttrType type, SeqEnd *seqend);
|
||||
|
||||
virtual ~Attr();
|
||||
|
||||
AttrType type() const { return type_; }
|
||||
Expr *expr() const { return expr_; }
|
||||
SeqEnd *seqend() const { return seqend_; }
|
||||
|
@ -47,6 +49,7 @@ protected:
|
|||
AttrType type_;
|
||||
Expr *expr_;
|
||||
SeqEnd *seqend_;
|
||||
bool delete_expr_;
|
||||
};
|
||||
|
||||
class LetAttr : public Attr
|
||||
|
|
|
@ -436,22 +436,21 @@ void CaseField::GenParseCode(Output* out_cc, Env* env,
|
|||
|
||||
{
|
||||
Env case_env(env, this);
|
||||
Env *env = &case_env;
|
||||
|
||||
type_->GenPreParsing(out_cc, env);
|
||||
type_->GenParseCode(out_cc, env, data, 0);
|
||||
type_->GenPreParsing(out_cc, &case_env);
|
||||
type_->GenParseCode(out_cc, &case_env, data, 0);
|
||||
if ( size_var )
|
||||
{
|
||||
out_cc->println("%s = %s;",
|
||||
env->LValue(size_var),
|
||||
type_->DataSize(out_cc, env, data).c_str());
|
||||
case_env.LValue(size_var),
|
||||
type_->DataSize(out_cc, &case_env, data).c_str());
|
||||
}
|
||||
if ( type_->incremental_input() )
|
||||
{
|
||||
ASSERT(case_type()->parsing_complete_var());
|
||||
out_cc->println("%s = %s;",
|
||||
env->LValue(case_type()->parsing_complete_var()),
|
||||
env->RValue(type_->parsing_complete_var()));
|
||||
case_env.LValue(case_type()->parsing_complete_var()),
|
||||
case_env.RValue(type_->parsing_complete_var()));
|
||||
}
|
||||
out_cc->println("}");
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ ConnDecl::~ConnDecl()
|
|||
{
|
||||
delete flows_[0];
|
||||
delete flows_[1];
|
||||
delete data_type_;
|
||||
}
|
||||
|
||||
void ConnDecl::AddBaseClass(vector<string> *base_classes) const
|
||||
|
|
|
@ -66,6 +66,7 @@ AnalyzerContextDecl::AnalyzerContextDecl(
|
|||
AnalyzerContextDecl::~AnalyzerContextDecl()
|
||||
{
|
||||
delete context_name_id_;
|
||||
delete param_type_;
|
||||
delete_list(ContextFieldList, context_fields_);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ ConstString::ConstString(const string &s)
|
|||
int len = strlen(text) + 1;
|
||||
int i = 0;
|
||||
|
||||
char* s = new char[len];
|
||||
char* new_s = new char[len];
|
||||
|
||||
// Skip leading quote.
|
||||
for ( ++text; *text; ++text )
|
||||
|
@ -95,22 +95,22 @@ ConstString::ConstString(const string &s)
|
|||
if ( *text == '\\' )
|
||||
{
|
||||
++text; // skip '\'
|
||||
s[i++] = expand_escape(text);
|
||||
new_s[i++] = expand_escape(text);
|
||||
--text; // point to end of sequence
|
||||
}
|
||||
else
|
||||
{
|
||||
s[i++] = *text;
|
||||
new_s[i++] = *text;
|
||||
}
|
||||
}
|
||||
ASSERT(i < len);
|
||||
|
||||
// Get rid of trailing quote.
|
||||
ASSERT(s[i-1] == '"');
|
||||
s[i-1] = '\0';
|
||||
ASSERT(new_s[i-1] == '"');
|
||||
new_s[i-1] = '\0';
|
||||
|
||||
unescaped_ = s;
|
||||
delete [] s;
|
||||
unescaped_ = new_s;
|
||||
delete [] new_s;
|
||||
}
|
||||
catch(EscapeException const &e)
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@ class DataPtr
|
|||
{
|
||||
public:
|
||||
DataPtr(Env* env, const ID* arg_id, const int arg_off);
|
||||
DataPtr(DataPtr const& x) { *this = x; }
|
||||
|
||||
DataPtr const &operator=(DataPtr const &x)
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
}
|
||||
~ID()
|
||||
{
|
||||
delete locname;
|
||||
delete [] locname;
|
||||
}
|
||||
|
||||
bool operator==(ID const &x) const { return name == x.Name(); }
|
||||
|
|
|
@ -8,9 +8,6 @@ namespace {
|
|||
|
||||
void GenLetEval(const ID *id, Expr *expr, string prefix, Output* out, Env* env)
|
||||
{
|
||||
if ( expr )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
} // private namespace
|
||||
|
|
|
@ -19,9 +19,6 @@ string PPSet::ToCode(Env *env)
|
|||
string PPType::ToCode(Env *env)
|
||||
{
|
||||
Type *type = expr_->DataType(env);
|
||||
if ( ! type )
|
||||
{
|
||||
}
|
||||
return type->DataTypeStr();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue