Cosmetics: Fix static analysis warnings

This commit is contained in:
Felipe Zimmerle
2015-10-27 10:54:57 -03:00
parent 11a1045f47
commit 7afc07914f
14 changed files with 39 additions and 30 deletions

View File

@@ -61,7 +61,6 @@ Action *Action::instantiate(const std::string& name) {
std::string block("block");
std::string phase("phase:");
std::string rule_id("id:");
std::string severity("severity:");
if (name.compare(0, status.length(), status) == 0) {
return new Status(name);

View File

@@ -33,7 +33,8 @@ namespace actions {
class RuleId : public Action {
public:
explicit RuleId(std::string action)
: Action(action, ConfigurationKind) { }
: Action(action, ConfigurationKind),
m_ruleId(0) { }
bool init(std::string *error) override;
bool evaluate(Rule *rule, Assay *assay) override;

View File

@@ -101,7 +101,6 @@ void SetVar::dump() {
bool SetVar::evaluate(Rule *rule, Assay *assay) {
std::string targetValue;
int value = 0;
std::string variableNameExpanded = MacroExpansion::expand(variableName,
assay);
std::string resolvedPre = MacroExpansion::expand(predicate, assay);
@@ -112,6 +111,8 @@ bool SetVar::evaluate(Rule *rule, Assay *assay) {
targetValue = std::string("1");
} else {
int pre = 0;
int value = 0;
try {
pre = stoi(resolvedPre);
} catch (...) {

View File

@@ -38,9 +38,7 @@ ReplaceComments::ReplaceComments(std::string action)
std::string ReplaceComments::evaluate(std::string value,
Assay *assay) {
uint64_t i, j, incomment;
int changed = 0;
char *input = reinterpret_cast<char *>(
malloc(sizeof(char) * value.size() + 1));
@@ -52,7 +50,6 @@ std::string ReplaceComments::evaluate(std::string value,
if (incomment == 0) {
if ((input[i] == '/') && (i + 1 < value.size())
&& (input[i + 1] == '*')) {
changed = 1;
incomment = 1;
i += 2;
} else {