Skip to content

Commit

Permalink
Fix some cppcheck reports:
Browse files Browse the repository at this point in the history
- (error) va_list '<var>' was opened but not closed by va_end()
- (style) Same expression on both sides of '||'
- (style) Same expression on both sides of '!='
  • Loading branch information
serval2412 authored and wwmayer committed Jan 6, 2015
1 parent 67ca966 commit b325bce
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
20 changes: 14 additions & 6 deletions src/Base/PyTools.c
Expand Up @@ -18,8 +18,8 @@ is provided on an as is basis, without warranties of any kind.
#include <eval.h>


#if PY_VERSION_HEX <= 0x02050000
#error "Use Python2.5.x or higher"
#if PY_VERSION_HEX <= 0x02050000
#error "Use Python2.5.x or higher"
#endif


Expand All @@ -46,7 +46,8 @@ PP_Run_Method(PyObject *pobject, const char *method,
// if(resfmt == 0 || strcmp(resfmt,"") == 0)
// pargs = Py_BuildValue("()");
// else
pargs = Py_VaBuildValue(argfmt, argslist); /* args: c->python */
pargs = Py_VaBuildValue(argfmt, argslist); /* args: c->python */
va_end(argslist);

if (pargs == NULL) {
Py_DECREF(pmeth);
Expand Down Expand Up @@ -87,7 +88,8 @@ PP_Set_Member(PyObject *pobject, const char *attrname,
va_start(argslist, argfmt);
Py_Initialize(); /* init if first time */
pval = Py_VaBuildValue(argfmt, argslist); /* input: C->Python */
if (pval == NULL)
va_end(argslist);
if (pval == NULL)
return -1;
result = PyObject_SetAttrString(pobject, attrname, pval); /* setattr */
Py_DECREF(pval);
Expand Down Expand Up @@ -116,9 +118,12 @@ PP_Run_Function(const char *modname, const char *funcname, /* load from
va_start(argslist, argfmt); /* "modname.funcname(args)" */

func = PP_Load_Attribute(modname, funcname); /* may reload; incref'd */
if (func == NULL) /* func or class or C type */
if (func == NULL) { /* func or class or C type */
va_end(argslist);
return -1;
}
args = Py_VaBuildValue(argfmt, argslist); /* convert args to python */
va_end(argslist);
if (args == NULL) { /* args incref'd */
Py_DECREF(func);
return -1;
Expand Down Expand Up @@ -172,6 +177,7 @@ PP_Run_Known_Callable(PyObject *object, /* func|class|method */

Py_Initialize();
args = Py_VaBuildValue(argfmt, argslist); /* convert args to python */
va_end(argslist);
if (args == NULL) /* args incref'd */
return -1;
if (PP_DEBUG) /* debug this call? */
Expand Down Expand Up @@ -345,8 +351,10 @@ PP_Set_Global(const char *modname, const char *varname, const char *valfmt, ...
va_start(cvals, valfmt); /* C args after valfmt */

module = PP_Load_Module(modname); /* get/load module */
if (module == NULL)
if (module == NULL) {
va_end(cvals);
return -1;
}
val = Py_VaBuildValue(valfmt, cvals); /* convert input to Python */
va_end(cvals);
if (val == NULL)
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Mesh/App/Core/Grid.cpp
Expand Up @@ -97,7 +97,7 @@ void MeshGrid::InitGrid (void)

// Grid Laengen berechnen wenn nicht initialisiert
//
if ((_ulCtGridsX == 0) || (_ulCtGridsX == 0) || (_ulCtGridsX == 0))
if ((_ulCtGridsX == 0) || (_ulCtGridsY == 0) || (_ulCtGridsZ == 0))
CalculateGridLength(MESH_CT_GRID, MESH_MAX_GRIDS);

// Grid Laengen und Offset bestimmen
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Points/App/PointsGrid.cpp
Expand Up @@ -130,7 +130,7 @@ void PointsGrid::InitGrid (void)

// Grid Laengen berechnen wenn nicht initialisiert
//
if ((_ulCtGridsX == 0) || (_ulCtGridsX == 0) || (_ulCtGridsX == 0))
if ((_ulCtGridsX == 0) || (_ulCtGridsY == 0) || (_ulCtGridsZ == 0))
CalculateGridLength(POINTS_CT_GRID, POINTS_MAX_GRIDS);

// Grid Laengen und Offset bestimmen
Expand Down
2 changes: 0 additions & 2 deletions src/Mod/Robot/App/kdl_cp/chainiksolvervel_pinv_givens.cpp
Expand Up @@ -52,8 +52,6 @@ namespace KDL

int ChainIkSolverVel_pinv_givens::CartToJnt(const JntArray& q_in, const Twist& v_in, JntArray& qdot_out)
{
toggle!=toggle;

jnt2jac.JntToJac(q_in,jac);

for(unsigned int i=0;i<6;i++)
Expand Down

0 comments on commit b325bce

Please sign in to comment.