Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/matrix1d.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ class Matrix1D
return;
}

coreDeallocate();
vdim = _vdim;
vdata = new T[vdim];
memset(vdata, 0, vdim * sizeof(T));
Expand Down
4 changes: 2 additions & 2 deletions core/matrix2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ void Matrix2D<T>::toVector(Matrix1D<T>& op1) const
if (VEC_XSIZE(op1)!=mdimx)
op1.resizeNoCopy(mdimx);

memcpy(&VEC_ELEM(op1,0),&MAT_ELEM(*this,0,0),mdimx*sizeof(double));
memcpy(&VEC_ELEM(op1,0),&MAT_ELEM(*this,0,0),mdimx*sizeof(T));

op1.setRow();
}
Expand Down Expand Up @@ -1286,7 +1286,7 @@ T** Matrix2D<T>::adaptForNumericalRecipes() const
for (int j = 0; j < mdimx; j++)
m[i+1][j+1] = mdata[i*mdimx + j];

return m;
return m; // NOSONAR - intentional 1-based NR pointer arithmetic
}

template<typename T>
Expand Down
2 changes: 1 addition & 1 deletion core/matrix2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ class Matrix2D
*/
inline T* adaptForNumericalRecipes2() const
{
return mdata - 1 - mdimx;
return mdata - 1 - mdimx; // NOSONAR - intentional 1-based NR pointer arithmetic
}

/** Load 2D array from numerical recipes result.
Expand Down
7 changes: 6 additions & 1 deletion core/metadata_static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,17 @@ bool MDL::isValidLabel(const String &labelName)

MDLabelType MDL::labelType(const MDLabel label)
{
if (!isValidLabel(label))
REPORT_ERROR(ERR_MD_BADLABEL, "Invalid label");
return data[label]->type;
}

MDLabelType MDL::labelType(const String &labelName)
{
return data[str2Label(labelName)]->type;
MDLabel label = str2Label(labelName);
if (!isValidLabel(label))
REPORT_ERROR(ERR_MD_BADLABEL, "Invalid label");
return data[label]->type;
}

std::map<String, MDLabel>& MDL::getLabelDict()
Expand Down
1 change: 1 addition & 0 deletions core/rwJPEG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
jpeg_finish_decompress( &cinfo );
jpeg_destroy_decompress( &cinfo );
delete[] row_pointer[0];
delete[] buffer;

Check failure on line 110 in core/rwJPEG.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rewrite the code so that you no longer need this "delete".

See more on https://sonarcloud.io/project/issues?id=I2PC_xmippCore&issues=AZ5t5aAL0Yo6vp7PmoQZ&open=AZ5t5aAL0Yo6vp7PmoQZ&pullRequest=233

return 0;
}
Expand Down
5 changes: 4 additions & 1 deletion core/xmipp_strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,16 @@ String integerToString(int I, int _width, char fill_with)
if (SGN(I) < 0)
width--;

if (width == 0)
if (width <= 0)
{
width = 0;
do
{
Iaux /= 10;
width++;
}
while (Iaux != 0);
}

// Fill the number with the fill character
for (int i = 0; i < width; i++)
Expand Down