Unverified Commit 0bc884fc authored by DannyHindson's avatar DannyHindson Committed by GitHub
Browse files

Merge pull request #32531 from DavidFair/cppcheck_cache

Cppcheck cache
parents 3ee31c71 30f7d72e
......@@ -48,7 +48,7 @@ public:
virtual ~ImplicitFunctionParameter() = default;
protected:
bool m_isValid;
bool m_isValid{false};
std::string parameterXMLTemplate(const std::string &valueXMLtext) const {
using namespace Poco::XML;
......
......@@ -387,7 +387,7 @@ void CorrectTOFAxis::averageL2AndEPP(const API::SpectrumInfo &spectrumInfo, doub
double eppSum = 0;
size_t n = 0;
const auto indexCount = static_cast<int64_t>(m_workspaceIndices.size());
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for if (m_eppTable->threadSafe())
reduction(+: n, l2Sum, eppSum))
for (int64_t i = 0; i < indexCount; ++i) {
......
......@@ -616,7 +616,7 @@ void CreateGroupingWorkspace::exec() {
sortnames = true;
GroupNames = "";
int maxRecurseDepth = this->getProperty("MaxRecursionDepth");
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 1) )
for (int num = 0; num < 300; ++num) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -371,7 +371,7 @@ void DiffractionFocussing2::execEvent() {
int chunkSize = 200;
int end = (totalHistProcess / chunkSize) + 1;
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 1) )
for (int wiChunk = 0; wiChunk < end; wiChunk++) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -990,9 +990,6 @@ int FindPeaks::findPeakBackground(const MatrixWorkspace_sptr &input, int spectru
// Local check whether FindPeakBackground gives a reasonable value
vecpeakrange.resize(2);
/// @todo Remove this cppcheck suppression when #13950 is fixed
// cppcheck-suppress knownConditionTrueFalse
if (fitresult > 0) {
// Use FitPeakBackgroud's result
size_t i_peakmin, i_peakmax;
......
......@@ -850,7 +850,6 @@ std::vector<std::shared_ptr<FitPeaksAlgorithm::PeakFitResult>> FitPeaks::fitPeak
const int nThreads = FrameworkManager::Instance().getNumOMPThreads();
size_t chunkSize = num_fit_result / nThreads;
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 1) )
for (int ithread = 0; ithread < nThreads; ithread++) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -1071,7 +1071,7 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesParallel(const map<size_t,
}
// Create event filters/splitters in parallel
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 1) )
for (int i = 0; i < numThreads; ++i) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -533,7 +533,7 @@ void PDCalibration::exec() {
// Scan the table containing the fit parameters for every peak, retrieve the
// parameters for peaks that were successfully fitting, then use this info
// to obtain difc, difa, and tzero for each pixel
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 1))
for (int wkspIndex = 0; wkspIndex < NUMHIST; ++wkspIndex) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -452,7 +452,7 @@ public:
const auto &yValues = outWS->histogram(i).y();
for (size_t j = 0; j < yValues.size(); ++j) {
if (specOutInfo.isMonitor(i))
// cppcheck-suppress syntaxError
TS_ASSERT_DELTA(yValues[j], double(j + 1) / 15.0, 1e-12)
else
TS_ASSERT_DELTA(yValues[j], 2.0 / 15.0, 1e-12)
......
......@@ -82,7 +82,7 @@ void SCDCalibratePanels::exec() {
MyPanels.insert("East");
MyPanels.insert("West");
int maxRecurseDepth = 4;
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 1) )
for (int num = 1; num < 64; ++num) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -28,20 +28,14 @@ public:
/// Constructor with vector of DateAndTime
BankPulseTimes(const std::vector<Mantid::Types::Core::DateAndTime> &times);
/// Destructor
~BankPulseTimes();
/// Equals
bool equals(size_t otherNumPulse, const std::string &otherStartTime);
/// String describing the start time
std::string startTime;
/// Size of the array of pulse times
size_t numPulses;
/// Array of the pulse times
Mantid::Types::Core::DateAndTime *pulseTimes;
std::vector<Mantid::Types::Core::DateAndTime> pulseTimes;
/// Vector of period numbers corresponding to each pulse
std::vector<int> periodNumbers;
......
......@@ -151,6 +151,10 @@ public:
FastReadOnlyFile(const char *filename);
~FastReadOnlyFile();
// Prevent copying of a file handle
FastReadOnlyFile(const FastReadOnlyFile &) = delete;
FastReadOnlyFile &operator=(FastReadOnlyFile) = delete;
// properties
void *handle() const;
......
......@@ -12,6 +12,7 @@
#include <nexus/NeXusFile.hpp>
#include <climits>
#include <memory>
namespace Mantid {
namespace DataHandling {
......@@ -52,7 +53,7 @@ private:
/// Overwrites Algorithm method
void exec() override;
ISISRAW2 m_isisRaw;
std::unique_ptr<ISISRAW2> m_isisRaw;
NXhandle handle;
FILE *rawFile;
std::vector<int> monitorData;
......
......@@ -39,32 +39,28 @@ BankPulseTimes::BankPulseTimes(::NeXus::File &file, const std::vector<int> &pNum
file.getData(seconds);
file.closeData();
// Now create the pulseTimes
numPulses = seconds.size();
if (numPulses == 0)
if (seconds.size() == 0)
throw std::runtime_error("event_time_zero field has no data!");
pulseTimes = new Mantid::Types::Core::DateAndTime[numPulses];
for (size_t i = 0; i < numPulses; i++)
pulseTimes[i] = start + seconds[i];
std::transform(seconds.cbegin(), seconds.cend(), std::back_inserter(pulseTimes),
[start](double seconds) { return start + seconds; });
} else if (heldTimeZeroType == ::NeXus::UINT64) {
std::vector<uint64_t> nanoseconds;
file.getData(nanoseconds);
file.closeData();
// Now create the pulseTimes
numPulses = nanoseconds.size();
if (numPulses == 0)
if (nanoseconds.size() == 0)
throw std::runtime_error("event_time_zero field has no data!");
pulseTimes = new Mantid::Types::Core::DateAndTime[numPulses];
for (size_t i = 0; i < numPulses; i++)
pulseTimes[i] = start + int64_t(nanoseconds[i]);
std::transform(nanoseconds.cbegin(), nanoseconds.cend(), std::back_inserter(pulseTimes),
[start](int64_t nanoseconds) { return start + nanoseconds; });
} else {
throw std::invalid_argument("Unsupported type for event_time_zero");
}
// Ensure that we always have a consistency between nPulses and
// periodNumbers containers
if (numPulses != pNumbers.size()) {
periodNumbers = std::vector<int>(numPulses, FirstPeriod);
if (pulseTimes.size() != pNumbers.size()) {
periodNumbers = std::vector<int>(pulseTimes.size(), FirstPeriod);
;
}
}
......@@ -75,19 +71,12 @@ BankPulseTimes::BankPulseTimes(::NeXus::File &file, const std::vector<int> &pNum
* @param times
*/
BankPulseTimes::BankPulseTimes(const std::vector<Mantid::Types::Core::DateAndTime> &times) {
numPulses = times.size();
pulseTimes = nullptr;
if (numPulses == 0)
if (times.size() == 0)
return;
pulseTimes = new Mantid::Types::Core::DateAndTime[numPulses];
periodNumbers = std::vector<int>(numPulses, FirstPeriod); // TODO we are fixing this at 1 period for all
for (size_t i = 0; i < numPulses; i++)
pulseTimes[i] = times[i];
}
//----------------------------------------------------------------------------------------------
/** Destructor */
BankPulseTimes::~BankPulseTimes() { delete[] this->pulseTimes; }
pulseTimes = times;
periodNumbers = std::vector<int>(pulseTimes.size(), FirstPeriod); // TODO we are fixing this at 1 period for all
}
//----------------------------------------------------------------------------------------------
/** Comparison. Is this bank's pulse times array the same as another one.
......@@ -99,5 +88,5 @@ BankPulseTimes::~BankPulseTimes() { delete[] this->pulseTimes; }
* reloaded.
*/
bool BankPulseTimes::equals(size_t otherNumPulse, const std::string &otherStartTime) {
return ((this->startTime == otherStartTime) && (this->numPulses == otherNumPulse));
return ((this->startTime == otherStartTime) && (this->pulseTimes.size() == otherNumPulse));
}
......@@ -377,7 +377,7 @@ void CreateChunkingFromInstrument::exec() {
// search the instrument for the bank names
int maxRecurseDepth = this->getProperty(PARAM_MAX_RECURSE);
map<string, vector<string>> grouping;
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 1) )
for (int num = 0; num < maxBankNum; ++num) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -871,7 +871,7 @@ void FilterEventsByLogValuePreNexus::procEvents(DataObjects::EventWorkspace_sptr
g_log.information() << "Processing input event preNexus by " << numThreads << " threads"
<< " in " << numBlocks << " blocks. "
<< "\n";
// cppcheck-suppress syntaxError
PRAGMA_OMP( parallel for schedule(dynamic, 1) if (m_parallelProcessing) )
for (int i = 0; i < int(numThreads); i++) {
// This is the partial workspace we are about to create (if in parallel)
......
......@@ -154,7 +154,7 @@ void EventAssignerFixedWavelength::addEventImpl(size_t id, int64_t pulse, double
m_eventVectors[id]->emplace_back(m_wavelength);
}
// FastReadOnlyFile
// ISISRawOnlyFile
#ifdef _WIN32
FastReadOnlyFile::FastReadOnlyFile(const char *filename) {
m_handle = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
......
......@@ -55,7 +55,7 @@ void LoadBankFromDiskTask::loadPulseTimes(::NeXus::File &file) {
return;
}
std::string thisStartTime;
size_t thisNumPulses = 0;
size_t thispulseTimes = 0;
// If the offset is not present, use Unix epoch
if (!file.hasAttr("offset")) {
thisStartTime = "1970-01-01T00:00:00Z";
......@@ -66,13 +66,13 @@ void LoadBankFromDiskTask::loadPulseTimes(::NeXus::File &file) {
}
if (!file.getInfo().dims.empty())
thisNumPulses = file.getInfo().dims[0];
thispulseTimes = file.getInfo().dims[0];
file.closeData();
// Now, we look through existing ones to see if it is already loaded
// thisBankPulseTimes = NULL;
for (auto &bankPulseTime : m_loader.m_bankPulseTimes) {
if (bankPulseTime->equals(thisNumPulses, thisStartTime)) {
if (bankPulseTime->equals(thispulseTimes, thisStartTime)) {
thisBankPulseTimes = bankPulseTime;
return;
}
......@@ -131,7 +131,7 @@ void LoadBankFromDiskTask::prepareEventId(::NeXus::File &file, int64_t &start_ev
stop_event = dim0;
// Handle the time filtering by changing the start/end offsets.
for (size_t i = 0; i < thisBankPulseTimes->numPulses; i++) {
for (size_t i = 0; i < thisBankPulseTimes->pulseTimes.size(); i++) {
if (thisBankPulseTimes->pulseTimes[i] >= m_loader.alg->filter_time_start) {
start_event = static_cast<int64_t>(event_index[i]);
break; // stop looking
......@@ -150,7 +150,7 @@ void LoadBankFromDiskTask::prepareEventId(::NeXus::File &file, int64_t &start_ev
start_event = 0;
stop_event = dim0;
} else {
for (size_t i = 0; i < thisBankPulseTimes->numPulses; i++) {
for (size_t i = 0; i < thisBankPulseTimes->pulseTimes.size(); i++) {
if (thisBankPulseTimes->pulseTimes[i] > m_loader.alg->filter_time_stop) {
stop_event = event_index[i];
break;
......@@ -353,7 +353,7 @@ void LoadBankFromDiskTask::run() {
// The event_index should be the same length as the pulse times from DAS
// logs.
if (event_index.size() != thisBankPulseTimes->numPulses)
if (event_index.size() != thisBankPulseTimes->pulseTimes.size())
m_loader.alg->getLogger().warning() << "Bank " << entry_name
<< " has a mismatch between the number of event_index entries "
"and the number of pulse times in event_time_zero.\n";
......
......@@ -985,7 +985,7 @@ void LoadEventNexus::loadEvents(API::Progress *const prog, const bool monitors)
filter_time_start = Types::Core::DateAndTime::minimum();
filter_time_stop = Types::Core::DateAndTime::maximum();
if (m_allBanksPulseTimes->numPulses > 0) {
if (m_allBanksPulseTimes->pulseTimes.size() > 0) {
// If not specified, use the limits of doubles. Otherwise, convert from
// seconds to absolute PulseTime
if (filter_time_start_sec != EMPTY_DBL()) {
......
......@@ -718,7 +718,7 @@ void LoadEventPreNexus2::procEvents(DataObjects::EventWorkspace_sptr &workspace)
partWorkspaces.resize(numThreads);
buffers.resize(numThreads);
eventVectors = new EventVector_pt *[numThreads];
// cppcheck-suppress syntaxError
PRAGMA_OMP( parallel for if (parallelProcessing) )
for (int i = 0; i < int(numThreads); i++) {
// This is the partial workspace we are about to create (if in parallel)
......
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