Skip to content

Commit fe24f96

Browse files
authored
Merge pull request #2484 from SCIInstitute/clean_warnings
Clean warnings
2 parents 8062b4f + f722fdf commit fe24f96

13 files changed

Lines changed: 45 additions & 21 deletions

File tree

Libs/Alignment/Procrustes3D.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void Procrustes3D::AlignTwoShapes(SimilarityTransform3D& transform, ShapeType& s
301301
}
302302

303303
// Rotation from SVD
304-
vnl_svd<RealType> svd(shapeMat.transpose());
304+
vnl_svd<RealType> svd(shapeMat.transpose().as_ref());
305305
newTransform.rotation = svd.V() * svd.U().transpose();
306306
transform.rotation = newTransform.rotation * transform.rotation;
307307

@@ -459,7 +459,7 @@ void Procrustes3D::AlignSourceToTarget(SimilarityTransform3D& transform, ShapeTy
459459
}
460460

461461
// Rotation from SVD
462-
vnl_svd<RealType> svd(shapeMat.transpose());
462+
vnl_svd<RealType> svd(shapeMat.transpose().as_ref());
463463
newTransform.rotation = svd.V() * svd.U().transpose();
464464
transform.rotation = newTransform.rotation;
465465

Libs/Alignment/Transforms/itkKernelTransform2.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ ::ComputeK( void )
396396
// Compute the block diagonal element, i.e. kernel for pi->pi
397397
// Can ignore GMatrix, since p1 - p1 = 0
398398
this->ComputeReflexiveG( p1, G );
399-
this->m_KMatrix.update( G, i * NDimensions, i * NDimensions );
399+
this->m_KMatrix.update( G.as_ref(), i * NDimensions, i * NDimensions );
400400
p2++; j++;
401401

402402
// Compute the upper (and copy into lower) triangular part of K
@@ -405,8 +405,8 @@ ::ComputeK( void )
405405
const InputVectorType s = p1.Value() - p2.Value();
406406
this->ComputeG( s, G );
407407
// write value in upper and lower triangle of matrix
408-
this->m_KMatrix.update( G, i * NDimensions, j * NDimensions );
409-
this->m_KMatrix.update( G, j * NDimensions, i * NDimensions );
408+
this->m_KMatrix.update( G.as_ref(), i * NDimensions, j * NDimensions );
409+
this->m_KMatrix.update( G.as_ref(), j * NDimensions, i * NDimensions );
410410
p2++; j++;
411411
}
412412
p1++; i++;
@@ -439,9 +439,9 @@ ::ComputeP( void )
439439
for( unsigned int j = 0; j < NDimensions; j++ )
440440
{
441441
temp = I * p[ j ];
442-
this->m_PMatrix.update( temp, i * NDimensions, j * NDimensions );
442+
this->m_PMatrix.update( temp.as_ref(), i * NDimensions, j * NDimensions );
443443
}
444-
this->m_PMatrix.update( I, i * NDimensions, NDimensions * NDimensions );
444+
this->m_PMatrix.update( I.as_ref(), i * NDimensions, NDimensions * NDimensions );
445445
}
446446

447447
} // end ComputeP()

Libs/Mesh/PreviewMeshQC/FEVTKExport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ bool FEVTKExport::ExportToStream(FEMesh &mesh, std::ostream &out)
105105
for (j = 0; j < m.Nodes();) {
106106
for (int k = 0; k < 9 && j + k < m.Nodes(); k++) {
107107
char buffer[1024];
108-
sprintf(buffer, "%15.10lg ", nodeShellThickness[j + k]);
108+
std::snprintf(buffer, sizeof(buffer), "%15.10lg ", nodeShellThickness[j + k]);
109109
out << buffer << "\n";
110110
}
111111
out << "\n";
@@ -124,7 +124,7 @@ bool FEVTKExport::ExportToStream(FEMesh &mesh, std::ostream &out)
124124
for (int k = 0; k < 9 && j + k < m.Nodes(); k++) {
125125
FENode& n = m.Node(j + k);
126126
char buffer[1024];
127-
sprintf(buffer, "%15.10lg ", n.m_ndata);
127+
std::snprintf(buffer, sizeof(buffer), "%15.10lg ", n.m_ndata);
128128
out << buffer << "\n";
129129
}
130130
out << "\n";

Libs/Optimize/Matrix/MixedEffectsShapeMatrix.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ class MixedEffectsShapeMatrix : public LegacyShapeMatrix {
199199
}
200200
}
201201

202+
#if defined(__GNUC__) && !defined(__clang__)
203+
#pragma GCC diagnostic push
204+
#pragma GCC diagnostic ignored "-Walloc-size-larger-than="
205+
#endif
202206
void EstimateParameters() {
203207
// std::cout << "Estimating params" << std::endl;
204208
// std::cout << "Explanatory: " << m_Expl << std::endl;
@@ -210,6 +214,14 @@ class MixedEffectsShapeMatrix : public LegacyShapeMatrix {
210214
this->m_NumIndividuals = num_shapes / this->GetTimeptsPerIndividual();
211215
int nr = X.rows(); // number of points*3
212216

217+
// Guard against invalid m_NumIndividuals
218+
if (m_NumIndividuals <= 0) {
219+
return;
220+
}
221+
222+
// Use local variable to help compiler understand value is positive
223+
const size_t num_individuals = static_cast<size_t>(m_NumIndividuals);
224+
213225
// set the sizes of random slope and intercept matrix
214226
m_SlopeRand.set_size(m_NumIndividuals, nr); // num_groups X num_points*3
215227
m_InterceptRand.set_size(m_NumIndividuals, nr); // num_groups X num_points*3
@@ -228,8 +240,8 @@ class MixedEffectsShapeMatrix : public LegacyShapeMatrix {
228240
identity_2.set_size(2, 2);
229241
identity_2.set_identity();
230242
vnl_matrix<double>*Ws = NULL, *Vs = NULL;
231-
Ws = new vnl_matrix<double>[m_NumIndividuals];
232-
Vs = new vnl_matrix<double>[m_NumIndividuals];
243+
Ws = new vnl_matrix<double>[num_individuals];
244+
Vs = new vnl_matrix<double>[num_individuals];
233245
for (int i = 0; i < m_NumIndividuals; i++) {
234246
Vs[i].set_size(m_TimeptsPerIndividual, m_TimeptsPerIndividual);
235247
Ws[i].set_size(m_TimeptsPerIndividual, m_TimeptsPerIndividual);
@@ -319,6 +331,9 @@ class MixedEffectsShapeMatrix : public LegacyShapeMatrix {
319331
// printf ("random: slopes %g %g, intercepts %g %g", m_SlopeRand(0,0), m_SlopeRand(1,0), m_InterceptRand(0,0),
320332
// m_InterceptRand(1,0));
321333
}
334+
#if defined(__GNUC__) && !defined(__clang__)
335+
#pragma GCC diagnostic pop
336+
#endif
322337

323338
//
324339
void Initialize() {

Libs/Optimize/Utils/OptimizationVisualizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ void OptimizationVisualizer::IterationCallback(ParticleSystem* particleSystem) {
125125
windowToImageFilter->Update();
126126

127127
vtkSmartPointer<vtkPNGWriter> writer = vtkSmartPointer<vtkPNGWriter>::New();
128-
char buffer[100];
129-
int n = sprintf(buffer, "%s/screenshot_%08d.png", this->screenshotDirectory.c_str(), iteration);
128+
char buffer[256];
129+
std::snprintf(buffer, sizeof(buffer), "%s/screenshot_%08d.png", this->screenshotDirectory.c_str(), iteration);
130130
writer->SetFileName(buffer);
131131
writer->SetInputConnection(windowToImageFilter->GetOutputPort());
132132
writer->Write();

Libs/Optimize/Utils/ParticleGaussianModeWriter.txx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void ParticleGaussianModeWriter<VDimension>::Update() const {
5757
for (unsigned int d = 0; d < (unsigned int)DomainsPerShape; d++) {
5858
char fp[255];
5959
std::string fn = m_FileName;
60-
::sprintf(fp, "domain%d", d);
60+
std::snprintf(fp, sizeof(fp), "domain%d", d);
6161
fn += fp;
6262

6363
int rowsperdomain = num_dims / DomainsPerShape;
@@ -95,7 +95,7 @@ void ParticleGaussianModeWriter<VDimension>::Update() const {
9595
}
9696

9797
char fp[255];
98-
::sprintf(fp, ".%d.%d.mode", s, modenum);
98+
std::snprintf(fp, sizeof(fp), ".%d.%d.mode", s, modenum);
9999
std::string tmpstr = fn + fp;
100100

101101
particles::write_particles_from_vector(tmpstr, modelist);

Studio/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ SET(STUDIO_UTILS_SRCS
176176
)
177177

178178
SET(STUDIO_UTILS_MOC_HDRS
179-
Utils/ImageLabel.h
179+
# Utils/ImageLabel.h - doesn't have Q_OBJECT, no moc needed
180180
)
181181

182182
SET(STUDIO_INTERFACE_SRCS
@@ -195,7 +195,7 @@ SET(STUDIO_INTERFACE_SRCS
195195
)
196196
SET(STUDIO_INTERFACE_MOC_HDRS
197197
Interface/CompareWidget.h
198-
Interface/CustomSlider.h
198+
# Interface/CustomSlider.h - doesn't have Q_OBJECT, no moc needed
199199
Interface/ExportImageDialog.h
200200
Interface/KeyboardShortcuts.h
201201
Interface/LogWindow.h

Studio/Interface/LogWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void LogWindow::add_message(MessageType message_type, QString message) {
4141
}
4242

4343
QListWidgetItem* item = new QListWidgetItem(message, this->ui_->history_list_);
44-
item->setTextColor(color);
44+
item->setForeground(color);
4545
this->ui_->history_list_->addItem(item);
4646
this->ui_->history_list_->setCurrentItem(item);
4747
}

Studio/Interface/SplashScreen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void SplashScreen::resizeEvent(QResizeEvent* event) {
127127
QDialog::resizeEvent(event);
128128

129129
QFontMetrics fm(this->ui_->title_->font());
130-
int width = fm.width(this->ui_->title_->text());
130+
int width = fm.horizontalAdvance(this->ui_->title_->text());
131131
this->ui_->title_->setMinimumWidth(width);
132132
this->resize(width * 2, width * 1.2);
133133
}

Studio/Optimize/OptimizeTool.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ QWidget#optimize_panel {
11481148
</widget>
11491149
</item>
11501150
<item row="0" column="0">
1151-
<spacer name="horizontalSpacer_13">
1151+
<spacer name="horizontalSpacer_13a">
11521152
<property name="orientation">
11531153
<enum>Qt::Horizontal</enum>
11541154
</property>
@@ -1161,7 +1161,7 @@ QWidget#optimize_panel {
11611161
</spacer>
11621162
</item>
11631163
<item row="0" column="2">
1164-
<spacer name="horizontalSpacer_14">
1164+
<spacer name="horizontalSpacer_14a">
11651165
<property name="orientation">
11661166
<enum>Qt::Horizontal</enum>
11671167
</property>

0 commit comments

Comments
 (0)