Skip to content

Commit

Permalink
Fix new warnings detected by codeQL (#1265)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson-numerical-software authored Oct 24, 2024
1 parent 2ad50dc commit 8fe7645
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 24 deletions.
1 change: 0 additions & 1 deletion modules/gui/src/cpp/QtWorkspaceBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ QtWorkspaceBrowser::updateVariables()
m_tableWidget->setRowCount((int)variablesList.size());

for (int i = 0; i < variablesList.size(); i++) {
bool isPersistent = m_context->isVariablePersistent(wstring_to_utf8(variablesList[i]));
bool isGlobal = m_context->isVariableGlobal(wstring_to_utf8(variablesList[i]));
ArrayOf* variable = m_context->lookupVariable(wstring_to_utf8(variablesList[i]));
if (variable) {
Expand Down
1 change: 0 additions & 1 deletion modules/hdf5/src/cpp/h5SaveLoadHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ getNelsonDimensions(hid_t fid, const std::string& location, const std::string& v
return res;
}
hid_t type = H5Aget_type(attr_id);
hsize_t sDim = H5Tget_size(type);
uint64* ptrUint64 = nullptr;
try {
ptrUint64 = new uint64[(size_t)dims[1]];
Expand Down
4 changes: 0 additions & 4 deletions modules/mex/src/cpp/MxStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ mxAddField(mxArray* pm, const char* fieldname)
void
mxRemoveField(mxArray* pm, int fieldnumber)
{
if (mxIsStruct(pm)) {
auto* ptr = (Nelson::ArrayOf*)pm->ptr;
Nelson::ArrayOf* qp = (Nelson::ArrayOf*)ptr->getDataPointer();
}
auto* ptr = (Nelson::ArrayOf*)pm->ptr;
Nelson::stringVector fieldnames = ptr->getFieldNames();
size_t fieldCount = ptr->getFieldNames().size();
Expand Down
3 changes: 0 additions & 3 deletions modules/os_functions/src/cpp/SystemCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ ParallelSystemCommand(const wstringVector& commands, const std::vector<uint64>&
size_t nbCommands = commands.size();
results.resize(nbCommands);
std::vector<SystemCommandTask*> taskList;

#if defined(__APPLE__) or (defined(_WIN32) && not defined(_WIN64))
for (ompIndexType k = 0; k < (ompIndexType)nbCommands; k++) {
SystemCommandTask* task = new SystemCommandTask();
Expand All @@ -84,8 +83,6 @@ ParallelSystemCommand(const wstringVector& commands, const std::vector<uint64>&
taskList[k]->evaluateCommand(commands[k], timeouts[k]);
}
#else
size_t nbThreadsMax = (size_t)NelsonConfiguration::getInstance()->getMaxNumCompThreads();
size_t nbThreads = std::min(nbCommands, nbThreadsMax);
std::vector<std::thread> threadList;
for (size_t k = 0; k < nbCommands; k++) {
try {
Expand Down
2 changes: 0 additions & 2 deletions modules/sparse/src/cpp/HorzCatSparseDouble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ HorzCatSparseDouble(ArrayOf A, ArrayOf B)
Dimensions dimsB = B.getDimensions();
indexType newRowsSize = dimsA.getRows();
indexType newColumnsSize = dimsA.getColumns() + dimsB.getColumns();
indexType newSize = newColumnsSize * newRowsSize;
Dimensions dimsC = Dimensions(newRowsSize, newColumnsSize);
try {
spMatC = new Eigen::SparseMatrix<doublecomplex, 0, signedIndexType>(
Expand All @@ -73,7 +72,6 @@ HorzCatSparseDouble(ArrayOf A, ArrayOf B)
Dimensions dimsB = B.getDimensions();
indexType newRowsSize = dimsA.getRows();
indexType newColumnsSize = dimsA.getColumns() + dimsB.getColumns();
indexType newSize = newColumnsSize * newRowsSize;
Dimensions dimsC = Dimensions(newRowsSize, newColumnsSize);
try {
spMatC
Expand Down
1 change: 0 additions & 1 deletion modules/sparse/src/cpp/HorzCatSparseLogical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ HorzCatSparseLogical(ArrayOf A, ArrayOf B)
Eigen::SparseMatrix<logical, 0, signedIndexType>* spMatC;
indexType newColumnsSize = dimsA.getColumns() + dimsB.getColumns();
indexType newRowsSize = dimsA.getRows();
indexType newSize = newColumnsSize * newRowsSize;
Dimensions dimsC = Dimensions(newRowsSize, newColumnsSize);
try {
spMatC = new Eigen::SparseMatrix<logical, 0, signedIndexType>(newRowsSize, newColumnsSize);
Expand Down
25 changes: 15 additions & 10 deletions modules/sparse/src/cpp/SparseType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ Eigen_SparseMatrixConstructor(NelsonType dclass, indexType rows, indexType cols,
switch (dclass) {
case NLS_LOGICAL: {
Eigen::SparseMatrix<logical, 0, signedIndexType>* spMat = nullptr;
try {
spMat = new Eigen::SparseMatrix<logical, 0, signedIndexType>(rows, cols);
} catch (const std::bad_alloc&) {
spMat = nullptr;
Error(ERROR_MEMORY_ALLOCATION);
}
return spMat;
} break;
case NLS_DOUBLE: {
Eigen::SparseMatrix<double, 0, signedIndexType>* spMat = nullptr;
Expand All @@ -345,18 +352,17 @@ Eigen_SparseMatrixConstructor(NelsonType dclass, indexType rows, indexType cols,
spMat = nullptr;
Error(ERROR_MEMORY_ALLOCATION);
}
indexType X = 0;
indexType Y = 0;
for (auto& i : m) {
for (auto& j : i) {
Eigen::SparseMatrix<double, 0, signedIndexType>* src
= (Eigen::SparseMatrix<double, 0, signedIndexType>*)(j.getDataPointer());
}
}
return spMat;
} break;
case NLS_DCOMPLEX: {
Eigen::SparseMatrix<doublecomplex, 0, signedIndexType>* spMat = nullptr;
Eigen::SparseMatrix<std::complex<double>, 0, signedIndexType>* spMat = nullptr;
try {
spMat = new Eigen::SparseMatrix<std::complex<double>, 0, signedIndexType>(rows, cols);
} catch (const std::bad_alloc&) {
spMat = nullptr;
Error(ERROR_MEMORY_ALLOCATION);
}
return spMat;
} break;
default: {
Error(_W("Unsupported type in SparseMatrixConstructor."));
Expand Down Expand Up @@ -888,7 +894,6 @@ Eigen_makeSparseFromIJVComplex(indexType rows, indexType cols, indexType nnz, in
auto* pV = (double*)cp;
indexType q = 0;
for (indexType k = 0; k < nnz; k++) {
bool isZeroValue = false;
/* Currently , for compatibility, complex values are not cumulative */
if (bScalarV) {
if (pV[0] || pV[1]) {
Expand Down
1 change: 0 additions & 1 deletion modules/stream_manager/src/cpp/FscanFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ FscanF(FILE* filepointer, const std::string& format, const std::string& encoding
char* dp = buff;
char* np;
char sv;
bool as64bit = false;
while (*dp) {
np = dp;
while ((*dp) && (*dp != '%')) {
Expand Down
1 change: 0 additions & 1 deletion modules/stream_manager/src/cpp/SscanfFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ FwscanF(FILE* filepointer, const std::wstring& format, double m, double n, bool
wchar_t* dp = buff;
wchar_t* np;
wchar_t sv;
bool as64bit = false;
while (*dp) {
pos = 0;
np = dp;
Expand Down

0 comments on commit 8fe7645

Please sign in to comment.