Skip to content

Commit

Permalink
Merge pull request opencog#1163 from serval2412/master
Browse files Browse the repository at this point in the history
Fix cppcheck reports:
  • Loading branch information
linas committed Dec 27, 2014
2 parents 03626a1 + bc5365c commit d5be107
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ ActionPlanID OCPlanner::doPlanning(const vector<State*>& goal,const vector<State
int negativeNum,satisfiedPreconNum;
checkRuleFitnessRoughly(r,curStateNode,satisfiedPreconNum,negativeNum,isNegativeGoal,isDiffStateOwnerType,preconImpossible,willAddCirle,contradictoryOtherGoal,needRollback);

if (isNegativeGoal || isDiffStateOwnerType || willAddCirle || contradictoryOtherGoal || willAddCirle || preconImpossible)
if (isNegativeGoal || isDiffStateOwnerType || willAddCirle || contradictoryOtherGoal || preconImpossible)
continue;

// this rule is positive for this goal, apply it.
Expand Down Expand Up @@ -3343,7 +3343,7 @@ bool OCPlanner::groundARuleNodeBySelectingNonNumericValues(RuleNode *ruleNode)

}

delete indexes;
delete [] indexes;

if (ruleNode->ParamCandidates.size() == 0)
{
Expand Down
1 change: 1 addition & 0 deletions opencog/learning/clustering/blopex/fortran_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,7 @@ zutilities_FortranMatrixPrint( utilities_FortranMatrix* mtx,
fprintf(fp,"%22.14e %22.14e \n",p->real,p->imag);
p += jump;
}
fclose(fp);

return 0;
}
1 change: 1 addition & 0 deletions opencog/nlp/chatbot/go-irc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ int got_privmsg(const char* params, irc_reply_data* ird, void* data)
else
{
conn->privmsg (msg_target, "Shell escapes disabled in this chatbot version\n");
free(cmdline);
return 0;
}
#endif /* ENABLE_SHELL_ESCAPES */
Expand Down
1 change: 1 addition & 0 deletions opencog/persist/file/SavingLoading.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ void SavingLoading::load(const char *fileName,
size_t rc = fread(&format, sizeof(char), 1, f);

if (! (rc == 1 && format & FULL_NETWORK_DUMP)) {
fclose(f);
throw RuntimeException(TRACE_INFO, "SavingLoading - invalid file format '%c'.", format);
}

Expand Down
2 changes: 1 addition & 1 deletion opencog/spatial/LocalSpaceMap2D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void LocalSpaceMap2D::load(FILE* fp)

addObject(std::string(id), metadata, isObstacle );

delete id;
delete [] id;
}
CHECK_FREAD;
}
Expand Down
1 change: 1 addition & 0 deletions opencog/util/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -2677,6 +2677,7 @@ double** distancematrix (int nrows, int ncolumns, double** data,
if (i < n) /* break condition encountered */
{ j = i;
for (i = 1; i < j; i++) free(matrix[i]);
free(matrix);
return NULL;
}

Expand Down
6 changes: 3 additions & 3 deletions opencog/util/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ typename tree<T, tree_node_allocator>::sibling_iterator tree<T, tree_node_alloca
// insert all siblings in new_first..new_last before orig_first
bool first=true;
pre_order_iterator ret;
while(1==1) {
while(true) {
pre_order_iterator tt=insert_subtree(pre_order_iterator(orig_first), pre_order_iterator(new_first));
if(first) {
ret=tt;
Expand All @@ -1381,7 +1381,7 @@ typename tree<T, tree_node_allocator>::sibling_iterator tree<T, tree_node_alloca
// erase old range of siblings
bool last=false;
tree_node *next=orig_first;
while(1==1) {
while(true) {
if(next==orig_last)
last=true;
next=next->next_sibling;
Expand Down Expand Up @@ -1461,7 +1461,7 @@ iter tree<T, tree_node_allocator>::reparent(iter position, sibling_iterator begi
last->next_sibling=0;

tree_node *pos=first;
while(1==1) {
while(true) {
pos->parent=position.node;
if(pos==last) break;
pos=pos->next_sibling;
Expand Down

0 comments on commit d5be107

Please sign in to comment.