Commit a200387f authored by David Fairbrother's avatar David Fairbrother
Browse files

Update suppressions list for cppcheck 1.9

parent 0228a728
...@@ -68,7 +68,7 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const { ...@@ -68,7 +68,7 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const {
throw std::logic_error(std::string("No Version for Peaks file")); throw std::logic_error(std::string("No Version for Peaks file"));
getWord(in, false); // tag getWord(in, false); // tag
std::string C_Facility = getWord(in, false); getWord(in, false); // C_Facility
getWord(in, false); // tag getWord(in, false); // tag
std::string C_Instrument = getWord(in, false); std::string C_Instrument = getWord(in, false);
...@@ -142,7 +142,7 @@ std::string LoadIsawPeaks::readHeader(const PeaksWorkspace_sptr &outWS, ...@@ -142,7 +142,7 @@ std::string LoadIsawPeaks::readHeader(const PeaksWorkspace_sptr &outWS,
throw std::logic_error(std::string("No Version for Peaks file")); throw std::logic_error(std::string("No Version for Peaks file"));
getWord(in, false); // tag getWord(in, false); // tag
std::string C_Facility = getWord(in, false); getWord(in, false); // C_Facility
getWord(in, false); // tag getWord(in, false); // tag
std::string C_Instrument = getWord(in, false); std::string C_Instrument = getWord(in, false);
......
...@@ -715,10 +715,10 @@ int ISISRAW::ioRAW(FILE *file, LOG_STRUCT *s, int len, bool from_file) { ...@@ -715,10 +715,10 @@ int ISISRAW::ioRAW(FILE *file, LOG_STRUCT *s, int len, bool from_file) {
int ISISRAW::ioRAW(FILE *file, LOG_LINE *s, int len, bool from_file) { int ISISRAW::ioRAW(FILE *file, LOG_LINE *s, int len, bool from_file) {
char padding[5]; char padding[5];
memset(padding, ' ', sizeof(padding)); memset(padding, ' ', sizeof(padding));
int i, nbytes_rounded; int i;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
ioRAW(file, &(s[i].len), 1, from_file); ioRAW(file, &(s[i].len), 1, from_file);
nbytes_rounded = 4 * (1 + (s[i].len - 1) / 4); int nbytes_rounded = 4 * (1 + (s[i].len - 1) / 4);
ioRAW(file, &(s[i].data), s[i].len, from_file); ioRAW(file, &(s[i].data), s[i].len, from_file);
ioRAW(file, padding, nbytes_rounded - s[i].len, from_file); ioRAW(file, padding, nbytes_rounded - s[i].len, from_file);
} }
...@@ -731,12 +731,11 @@ int ISISRAW::ioRAW(FILE *file, char *s, int len, bool from_file) { ...@@ -731,12 +731,11 @@ int ISISRAW::ioRAW(FILE *file, char *s, int len, bool from_file) {
return 0; return 0;
} }
size_t n;
if (from_file) { if (from_file) {
n = fread(s, sizeof(char), len, file); size_t n = fread(s, sizeof(char), len, file);
return static_cast<int>(n - len); return static_cast<int>(n - len);
} else { } else {
n = fwrite(s, sizeof(char), len, file); fwrite(s, sizeof(char), len, file);
} }
return 0; return 0;
...@@ -748,12 +747,11 @@ int ISISRAW::ioRAW(FILE *file, int *s, int len, bool from_file) { ...@@ -748,12 +747,11 @@ int ISISRAW::ioRAW(FILE *file, int *s, int len, bool from_file) {
return 0; return 0;
} }
size_t n;
if (from_file) { if (from_file) {
n = fread(s, sizeof(int), len, file); size_t n = fread(s, sizeof(int), len, file);
return static_cast<int>(n - len); return static_cast<int>(n - len);
} else { } else {
n = fwrite(s, sizeof(int), len, file); fwrite(s, sizeof(int), len, file);
} }
return 0; return 0;
...@@ -765,12 +763,11 @@ int ISISRAW::ioRAW(FILE *file, uint32_t *s, int len, bool from_file) { ...@@ -765,12 +763,11 @@ int ISISRAW::ioRAW(FILE *file, uint32_t *s, int len, bool from_file) {
return 0; return 0;
} }
size_t n;
if (from_file) { if (from_file) {
n = fread(s, sizeof(uint32_t), len, file); size_t n = fread(s, sizeof(uint32_t), len, file);
return static_cast<int>(n - len); return static_cast<int>(n - len);
} else { } else {
n = fwrite(s, sizeof(uint32_t), len, file); fwrite(s, sizeof(uint32_t), len, file);
} }
return 0; return 0;
} }
...@@ -782,14 +779,13 @@ int ISISRAW::ioRAW(FILE *file, float *s, int len, bool from_file) { ...@@ -782,14 +779,13 @@ int ISISRAW::ioRAW(FILE *file, float *s, int len, bool from_file) {
return 0; return 0;
} }
size_t n;
if (from_file) { if (from_file) {
n = fread(s, sizeof(float), len, file); size_t n = fread(s, sizeof(float), len, file);
vaxf_to_local(s, &len, &errcode); vaxf_to_local(s, &len, &errcode);
return static_cast<int>(n - len); return static_cast<int>(n - len);
} else { } else {
local_to_vaxf(s, &len, &errcode); local_to_vaxf(s, &len, &errcode);
n = fwrite(s, sizeof(float), len, file); fwrite(s, sizeof(float), len, file);
vaxf_to_local(s, &len, &errcode); vaxf_to_local(s, &len, &errcode);
} }
return 0; return 0;
...@@ -942,6 +938,7 @@ int ISISRAW::vmstime(char *timbuf, int len, time_t time_value) { ...@@ -942,6 +938,7 @@ int ISISRAW::vmstime(char *timbuf, int len, time_t time_value) {
* get time in VMS format 01-JAN-1970 00:00:00 * get time in VMS format 01-JAN-1970 00:00:00
*/ */
size_t i, n; size_t i, n;
// cppcheck-suppress redundantAssignment
struct tm *tmstruct = nullptr; struct tm *tmstruct = nullptr;
#ifdef MS_VISUAL_STUDIO #ifdef MS_VISUAL_STUDIO
errno_t err = localtime_s(tmstruct, &time_value); errno_t err = localtime_s(tmstruct, &time_value);
......
...@@ -79,7 +79,7 @@ private: ...@@ -79,7 +79,7 @@ private:
void saveDataFiles(std::vector<ICat4::xsd__anyType *> response, void saveDataFiles(std::vector<ICat4::xsd__anyType *> response,
API::ITableWorkspace_sptr &outputws); API::ITableWorkspace_sptr &outputws);
// Saves "DataSets" information to the output workspace. // Saves "DataSets" information to the output workspace.
void saveDataSets(const std::vector<ICat4::xsd__anyType *> &response, void saveDataSets(std::vector<ICat4::xsd__anyType *> response,
API::ITableWorkspace_sptr &outputws); API::ITableWorkspace_sptr &outputws);
// Convert a file size to human readable file format. // Convert a file size to human readable file format.
std::string bytesToString(int64_t &fileSize); std::string bytesToString(int64_t &fileSize);
......
...@@ -24,7 +24,7 @@ namespace { ...@@ -24,7 +24,7 @@ namespace {
std::vector<std::string> namesOfFacilitiesWithICAT() { std::vector<std::string> namesOfFacilitiesWithICAT() {
const auto &config = Kernel::ConfigService::Instance(); const auto &config = Kernel::ConfigService::Instance();
const auto facilityDoesNotHaveICAT = [&](const std::string &name) { const auto facilityDoesNotHaveICAT = [&](std::string name) {
return config.getFacility(name).catalogInfo().soapEndPoint().empty(); return config.getFacility(name).catalogInfo().soapEndPoint().empty();
}; };
......
...@@ -435,7 +435,7 @@ void ICat4Catalog::getDataSets(const std::string &investigationId, ...@@ -435,7 +435,7 @@ void ICat4Catalog::getDataSets(const std::string &investigationId,
* @param response :: A vector containing the results of the search query. * @param response :: A vector containing the results of the search query.
* @param outputws :: Shared pointer to output workspace. * @param outputws :: Shared pointer to output workspace.
*/ */
void ICat4Catalog::saveDataSets(const std::vector<xsd__anyType *> &response, void ICat4Catalog::saveDataSets(std::vector<xsd__anyType *> response,
API::ITableWorkspace_sptr &outputws) { API::ITableWorkspace_sptr &outputws) {
if (outputws->getColumnNames().empty()) { if (outputws->getColumnNames().empty()) {
// Add rows headers to the output workspace. // Add rows headers to the output workspace.
......
...@@ -86,10 +86,10 @@ typedef struct { ...@@ -86,10 +86,10 @@ typedef struct {
/* wait until read len bytes, return <=0 on error */ /* wait until read len bytes, return <=0 on error */
static int recv_all(SOCKET s, void *buffer, int len, int flags) { static int recv_all(SOCKET s, void *buffer, int len, int flags) {
auto *cbuffer = reinterpret_cast<char *>(buffer); auto *cbuffer = reinterpret_cast<char *>(buffer);
int n, ntot; int ntot;
ntot = 0; ntot = 0;
while (len > 0) { while (len > 0) {
n = recv(s, cbuffer, len, flags); int n = recv(s, cbuffer, len, flags);
if (n <= 0) { if (n <= 0) {
return n; /* error */ return n; /* error */
} }
...@@ -283,7 +283,7 @@ int isisds_send_command(SOCKET s, const char *command, const void *data, ...@@ -283,7 +283,7 @@ int isisds_send_command(SOCKET s, const char *command, const void *data,
static int isisds_recv_command_helper(SOCKET s, char **command, void **data, static int isisds_recv_command_helper(SOCKET s, char **command, void **data,
ISISDSDataType *type, int dims_array[], ISISDSDataType *type, int dims_array[],
int *ndims, int do_alloc) { int *ndims, int do_alloc) {
int n, len_data, size_in, i; int n, len_data, i;
isisds_command_header_t comm; isisds_command_header_t comm;
n = recv_all(s, reinterpret_cast<char *>(&comm), sizeof(comm), 0); n = recv_all(s, reinterpret_cast<char *>(&comm), sizeof(comm), 0);
if (n != sizeof(comm)) { if (n != sizeof(comm)) {
...@@ -308,7 +308,7 @@ static int isisds_recv_command_helper(SOCKET s, char **command, void **data, ...@@ -308,7 +308,7 @@ static int isisds_recv_command_helper(SOCKET s, char **command, void **data,
*data = malloc(len_data + 1); *data = malloc(len_data + 1);
(reinterpret_cast<char *>(*data))[len_data] = '\0'; (reinterpret_cast<char *>(*data))[len_data] = '\0';
} else { } else {
size_in = 1; int size_in = 1;
for (i = 0; i < *ndims; i++) { for (i = 0; i < *ndims; i++) {
size_in *= dims_array[i]; size_in *= dims_array[i];
} }
......
...@@ -11,8 +11,10 @@ if ( CPPCHECK_EXECUTABLE ) ...@@ -11,8 +11,10 @@ if ( CPPCHECK_EXECUTABLE )
# setup the standard arguments # setup the standard arguments
set ( CPPCHECK_ARGS --enable=all --inline-suppr --max-configs=120 set ( CPPCHECK_ARGS --enable=all --inline-suppr --max-configs=120
--suppressions-list=${CMAKE_BINARY_DIR}/CppCheck_Suppressions.txt --suppressions-list=${CMAKE_BINARY_DIR}/CppCheck_Suppressions.txt
--suppress=*:*${CMAKE_BINARY_DIR}/*
--project=${CMAKE_BINARY_DIR}/compile_commands.json --project=${CMAKE_BINARY_DIR}/compile_commands.json
# Force cppcheck to check when we use project-wide macros
-DDLLExport=
-DMANTID_ALGORITHMS_DLL=
) )
set (_cppcheck_args "${CPPCHECK_ARGS}") set (_cppcheck_args "${CPPCHECK_ARGS}")
......
// suppress specific rule in specific files // suppress specific rule in specific files
// NOTE this needs the full path to the file, so would need this file to be generated by cmake // NOTE this needs the full path to the file, so would need this file to be generated by cmake
// as different build servers have different starts to the file path // as different build servers have different starts to the file path
// Example:
// memsetClassFloat:/Users/builder/Jenkins/workspace/cppcheck-1.72/
// -------- Project Wide ------------------
// Hide warnings about using explicit keyword constructors as we have "too many" // Hide warnings about using explicit keyword constructors as we have "too many"
noExplicitConstructor // and automated clang-tidy breaks a couple of implicit conversions we use widely
\ No newline at end of file noExplicitConstructor
// Hide warnings about shadowed members for inheritance. Typically "m_log" with Algorithm
duplInheritedMember
// We have some potentially uninitialized member vars but too many to fix at the moment
uninitMemberVar
// Cppcheck struggles with some inheritance chains, some of these might be true though
unusedPrivateFunction
// Nice to have, not need to have at the moment
useInitializationList
// A large number of copying instead of pass by ref were picked up by clang-tidy, but around 200 remain
passedByValue
// Around 100 of these exist where noConstructor is present
noConstructor
// Pre-processor Directives, such as #error, which are upstream anyway
preprocessorErrorDirective
// ---------- cppcheck 1.90 Transition -------
// If-init not supported
syntaxError:${CMAKE_SOURCE_DIR}/Framework/API/src/MatrixWorkspace.cpp
// ---------- Individual suppressions -----------------
// Mantid Plot specific ones we probably won't fix before removal
cstyleCase:*${CMAKE_SOURCE_DIR}/MantidPlot
*:${CMAKE_SOURCE_DIR}/MantidPlot/src/origin/tree.hh
*:${CMAKE_SOURCE_DIR}/MantidPlot/src/nrutil.cpp
// Macro expansion means this is incorrectly flagged on Unix
redundantAssignment:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRaw/isisraw.cpp
// Ones below was beyond the Cppcheck 1.90 migration scope
pureVirtualCall:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp
// Ref binding means Cppcheck can't see these are used
unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/MaskBinsIf.cpp
// --------- Missing copy assignment / constructors -------------------
// We don't want more creeping in so just mark these one by one
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/BoxController.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/ExperimentInfo.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/IFunction.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/MDGeometry.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/SingleValueParameter.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/VectorParameter.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Catalog/inc/MantidCatalog/ONCat.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Catalog/inc/MantidCatalog/ONCatEntity.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtWorkspaceBinData.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtWorkspaceSpectrumData.h
noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h
noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRaw/isisraw.h
// ----------------- Upstream libs ---------------
// Always ignore bin dir
*:*${CMAKE_BINARY_DIR}/*
// For some reason upstream libs sometimes end up in the check results
*:*/usr/include/*
// All ANN files as they are upstream anyway
*:*${CMAKE_SOURCE_DIR}/Framework/Kernel/src/ANN/*
// Libs we have in-source
*:*${CMAKE_SOURCE_DIR}/Framework/DataObjects/inc/MantidDataObjects/MortonIndex/*
*:*${CMAKE_SOURCE_DIR}/Framework/ICat/src/GSoap/*
*:*${CMAKE_SOURCE_DIR}/ICat/src/ICat3/GSoapGenerated/*
*:*${CMAKE_SOURCE_DIR}/ICat/src/ICat4/GSoapGenerated/*
*:*${CMAKE_SOURCE_DIR}/MantidPlot/src/zlib123/*
...@@ -13,7 +13,9 @@ IndirectBayesTab::IndirectBayesTab(QWidget *parent) ...@@ -13,7 +13,9 @@ IndirectBayesTab::IndirectBayesTab(QWidget *parent)
: IndirectTab(parent), m_propTree(new QtTreePropertyBrowser()) { : IndirectTab(parent), m_propTree(new QtTreePropertyBrowser()) {
m_propTree->setFactoryForManager(m_dblManager, m_dblEdFac); m_propTree->setFactoryForManager(m_dblManager, m_dblEdFac);
// cppcheck-suppress pureVirtualCall
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
// cppcheck-suppress pureVirtualCall
SLOT(updateProperties(QtProperty *, double))); SLOT(updateProperties(QtProperty *, double)));
} }
......
...@@ -216,11 +216,11 @@ IndirectDataTablePresenter::getSpectra(TableRowIndex start, ...@@ -216,11 +216,11 @@ IndirectDataTablePresenter::getSpectra(TableRowIndex start,
while (start < end) { while (start < end) {
WorkspaceIndex minimum = getWorkspaceIndex(start); WorkspaceIndex minimum = getWorkspaceIndex(start);
WorkspaceIndex maximum = minimum; WorkspaceIndex maximum = minimum;
start++; ++start;
while (start < end && while (start < end &&
getWorkspaceIndex(start) == maximum + WorkspaceIndex{1}) { getWorkspaceIndex(start) == maximum + WorkspaceIndex{1}) {
++maximum; ++maximum;
start++; ++start;
} }
spectraPairs.emplace_back(minimum, maximum); spectraPairs.emplace_back(minimum, maximum);
} }
......
...@@ -308,15 +308,12 @@ void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) { ...@@ -308,15 +308,12 @@ void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) {
} else { } else {
WidgetItem *par = parentItem->parent; WidgetItem *par = parentItem->parent;
QGridLayout *l = nullptr; QGridLayout *l = nullptr;
int oldRow = -1;
if (!par) { if (!par) {
l = m_mainLayout; l = m_mainLayout;
oldRow = m_children.indexOf(parentItem); m_children.indexOf(parentItem);
} else { } else {
l = par->layout; l = par->layout;
oldRow = par->children.indexOf(parentItem); par->children.indexOf(parentItem);
if (hasHeader(par))
oldRow += 2;
} }
if (parentItem->widget) { if (parentItem->widget) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment