Skip to content

Commit

Permalink
Remove unused variables and suppress other gcc warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbianco committed Dec 20, 2023
1 parent 88da27e commit 453e450
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 35 deletions.
3 changes: 0 additions & 3 deletions OpenSim/Actuators/FiberForceLengthCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ double FiberForceLengthCurve::calcCurvinessOfBestFit(double e0, double e1,
int maxIter = 20;
int iter = 0;
int localIter = 0;
int evalIter = 0;

while(iter < maxIter && abs(err) > relTol) {
flag_improvement = false;
Expand Down Expand Up @@ -390,8 +389,6 @@ double FiberForceLengthCurve::calcCurvinessOfBestFit(double e0, double e1,
}
}

evalIter += localIter;

step = step/2.0;
iter++;
}
Expand Down
7 changes: 4 additions & 3 deletions OpenSim/Actuators/Test/testMuscles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,12 @@ void simulateMuscle(
model.getMultibodySystem().realize(si, SimTK::Stage::Acceleration);

double Emuscle0 = muscWorkProbe->getProbeOutputs(si)(0);
//cout << "Muscle initial energy = " << Emuscle0 << endl;
log_debug("Muscle initial energy = {}", Emuscle0);
double Esys0 = model.getMultibodySystem().calcEnergy(si);
Esys0 += (Emuscle0 + jointWorkProbe->getProbeOutputs(si)(0));
/*double PEsys0 = */model.getMultibodySystem().calcPotentialEnergy(si);
//cout << "Total initial system energy = " << Esys0 << endl;
double PEsys0 = model.getMultibodySystem().calcPotentialEnergy(si);
log_debug("Total initial system energy = {}", Esys0);
log_debug("System potential energy = {}", PEsys0);

//==========================================================================
// 4. SIMULATION Integration
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Analyses/BodyKinematics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ constructDescription()
strcat(descrip, "velocities and angular velocities, or");
strcat(descrip, " accelerations and angular accelerations)\n");
strcat(descrip, "of the centers of mass");
sprintf(tmp, " of the body segments in model %s.\n",
snprintf(tmp, MAXLEN, " of the body segments in model %s.\n",
_model->getName().c_str());
strcat(descrip, tmp);
strcat(descrip, "\nBody segment orientations are described using");
Expand Down
4 changes: 2 additions & 2 deletions OpenSim/Analyses/ForceReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,12 @@ void ForceReporter::tidyForceNames()
bool validNameFound=false;
char pad[100];
// Make up a candidate name
sprintf(pad, "%s%d",
snprintf(pad, 100, "%s%d",
forces.get(i).getConcreteClassName().c_str(), j++);
while(!validNameFound){
validNameFound = (forceNames.findIndex(string(pad))== -1);
if (!validNameFound){
sprintf(pad, "Force%d", j++);
snprintf(pad, 100, "Force%d", j++);
}
}
string newName(pad);
Expand Down
6 changes: 3 additions & 3 deletions OpenSim/Common/GCVSplineSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ void GCVSplineSet::construct(int aDegree,

// GET COLUMN NAMES
const Array<std::string> &labels = aStore->getColumnLabels();
char tmp[32];
std::string name;

// LOOP THROUGH THE STATES
Expand All @@ -111,7 +110,8 @@ void GCVSplineSet::construct(int aDegree,
if(i+1 < labels.getSize()) {
name = labels[i+1];
} else {
sprintf(tmp,"data_%d",i);
char tmp[32];
snprintf(tmp, 32, "data_%d", i);
name = tmp;
}

Expand Down Expand Up @@ -178,7 +178,7 @@ Storage* GCVSplineSet::constructStorage(int aDerivOrder,double aDX) {
spline = getGCVSpline(i);
if(spline==NULL) {
char cName[32];
sprintf(cName,"data_%d",i);
snprintf(cName, 32, "data_%d", i);
labels.append(std::string(cName));
} else {
labels.append(spline->getName());
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Common/PropertyTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ toString() const
char pad[256];
double rawData[6];
getRotationsAndTranslationsAsArray6(rawData);
sprintf(pad, "%g %g %g %g %g %g", rawData[0], rawData[1], rawData[2], rawData[3], rawData[4], rawData[5]);
snprintf(pad, 256, "%g %g %g %g %g %g", rawData[0], rawData[1], rawData[2], rawData[3], rawData[4], rawData[5]);
str += string(pad);
str += ")";
return str;
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Common/SmoothSegmentedFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ DerivativeValues calcSelectedDerivatives(
MAXITER);

const SimTK::Array_<SimTK::Vec6>& ctrlPtsY = smoothData->_ctrlPtsY;
for (size_t i = 0; i < y.size(); ++i) {
for (int i = 0; i < static_cast<int>(y.size()); ++i) {
if (selectedOrders[i]) {
y.at(i) = SegmentedQuinticBezierToolkit::
calcQuinticBezierCurveDerivDYDX(
Expand Down
10 changes: 1 addition & 9 deletions OpenSim/Moco/MocoCasADiSolver/MocoCasOCProblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,15 @@ MocoCasOCProblem::MocoCasOCProblem(const MocoCasADiSolver& mocoCasADiSolver,
"model.");
} else {

int cid, mp, mv, ma;
int cid, mv, ma;
int multIndexThisConstraint;
int total_mp = 0;
int total_mv = 0;
int total_ma = 0;
std::vector<KinematicLevel> kinLevels;
const bool enforceConstraintDerivs =
mocoCasADiSolver.get_enforce_constraint_derivatives();
for (const auto& kcName : kcNames) {
const auto& kc = problemRep.getKinematicConstraint(kcName);
const auto& multInfos = problemRep.getMultiplierInfos(kcName);
cid = kc.getSimbodyConstraintIndex();
mp = kc.getNumPositionEquations();
mv = kc.getNumVelocityEquations();
ma = kc.getNumAccelerationEquations();
kinLevels = kc.getKinematicLevels();
Expand All @@ -142,10 +138,6 @@ MocoCasOCProblem::MocoCasOCProblem(const MocoCasADiSolver& mocoCasADiSolver,
"model Constraint at ConstraintIndex {}.",
ma, cid);

total_mp += mp;
total_mv += mv;
total_ma += ma;

// Loop through all scalar constraints associated with the model
// constraint and corresponding path constraints to the optimal
// control problem.
Expand Down
2 changes: 0 additions & 2 deletions OpenSim/Moco/MocoUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ TimeSeriesTable OpenSim::createExternalLoadsTableForGait(Model model,
const std::vector<std::string>& forcePathsLeftFoot) {
model.initSystem();
TimeSeriesTableVec3 externalForcesTable;
int count = 0;
for (const auto& state : trajectory) {
model.realizeDynamics(state);
SimTK::Vec3 sphereForcesRight(0);
Expand Down Expand Up @@ -339,7 +338,6 @@ TimeSeriesTable OpenSim::createExternalLoadsTableForGait(Model model,
row(4) = sphereTorquesRight;
row(5) = sphereTorquesLeft;
externalForcesTable.appendRow(state.getTime(), row);
++count;
}
// Create table.
std::vector<std::string> labels{"ground_force_r_v", "ground_force_r_p",
Expand Down
4 changes: 2 additions & 2 deletions OpenSim/Simulation/Control/ControlLinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,11 +698,11 @@ simplify(const PropertySet &aProperties)

// ADD NEW NODES
int newSize = t.getSize();
char name[32];
ControlLinearNode *node;
for(i=0;i<newSize;i++) {
char name[32];
node = new ControlLinearNode(t[i],xFilt[i]);
sprintf(name,"%d",i);
snprintf(name, 32, "%d", i);
node->setName(name);
_xNodes.append(node);
}
Expand Down
4 changes: 2 additions & 2 deletions OpenSim/Simulation/Control/ControlLinearNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ toString()
const char *format = IO::GetDoubleOutputFormat();

strcpy(string,"t=");
sprintf(tmp,format,_t);
snprintf(tmp,128,format,_t);
strcat(string,tmp);

strcat(string," value=");
sprintf(tmp,format,_value);
snprintf(tmp,128,format,_value);
strcat(string,tmp);

return(string);
Expand Down
4 changes: 2 additions & 2 deletions OpenSim/Simulation/Model/GeometryPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ void GeometryPath::constructProperties()
*/
void GeometryPath::namePathPoints(int aStartingIndex)
{
char indx[5];
for (int i = aStartingIndex; i < get_PathPointSet().getSize(); i++)
{
sprintf(indx,"%d",i+1);
char indx[5];
snprintf(indx,5,"%d",i+1);
AbstractPathPoint& point = get_PathPointSet().get(i);
if (point.getName()=="" && hasOwner()) {
point.setName(getOwner().getName() + "-P" + indx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void CoordinateCouplerConstraint::extendAddToSystem(SimTK::MultibodySystem& syst
mob_bodies.push_back(aCoordinate._bodyIndex);
mob_qs.push_back(SimTK::MobilizerQIndex(aCoordinate._mobilizerQIndex));

if (!mob_qs.size() & (mob_qs.size() != mob_bodies.size())) {
if (!mob_qs.size() && (mob_qs.size() != mob_bodies.size())) {
errorMessage = "CoordinateCouplerConstraint:: requires at least one body and coordinate." ;
throw (Exception(errorMessage));
}
Expand Down
7 changes: 4 additions & 3 deletions OpenSim/Simulation/Test/testProbes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,12 @@ void simulateMuscle(
model.getMultibodySystem().realize(si, SimTK::Stage::Acceleration);

double Emuscle0 = muscWorkProbe->getProbeOutputs(si)(0);
//cout << "Muscle initial energy = " << Emuscle0 << endl;
log_debug("Muscle initial energy = {}", Emuscle0);
double Esys0 = model.getMultibodySystem().calcEnergy(si);
Esys0 += (Emuscle0 + jointWorkProbe->getProbeOutputs(si)(0));
/*double PEsys0 = */model.getMultibodySystem().calcPotentialEnergy(si);
//cout << "Total initial system energy = " << Esys0 << endl;
double PEsys0 = model.getMultibodySystem().calcPotentialEnergy(si);
log_debug("Total system initial energy = {}", Esys0);
log_debug("System potential energy = {}", PEsys0);

//==========================================================================
// 4. SIMULATION Integration
Expand Down

0 comments on commit 453e450

Please sign in to comment.