diff --git a/.clang-tidy b/.clang-tidy index be4381b08..b1dfd03d3 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -19,6 +19,7 @@ Checks: '*, -google-readability-braces-around-statements, -modernize-use-trailing-return-type, -readability-isolate-declaration, + -readability-implicit-bool-conversion, -llvmlibc-*' HeaderFilterRegex: \.h diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index ede68129c..c38668507 100644 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -42,14 +42,10 @@ DataProcessor::DataProcessor(int index, detectorType detectorType, Fifo *fifo, ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false) { LOG(logDEBUG) << "DataProcessor " << index << " created"; - - memset((void *)&timerbegin_, 0, sizeof(timespec)); } DataProcessor::~DataProcessor() { DeleteFiles(); } -/** getters */ - bool DataProcessor::GetStartedFlag() const { return startedFlag_; } void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; } @@ -66,10 +62,8 @@ void DataProcessor::ResetParametersforNewAcquisition() { void DataProcessor::RecordFirstIndex(uint64_t fnum) { // listen to this fnum, later +1 currentFrameIndex_ = fnum; - startedFlag_ = true; firstIndex_ = fnum; - LOG(logDEBUG1) << index << " First Index:" << firstIndex_; } @@ -84,10 +78,8 @@ void DataProcessor::CloseFiles() { void DataProcessor::DeleteFiles() { CloseFiles(); - if (dataFile_) { - delete dataFile_; - dataFile_ = nullptr; - } + delete dataFile_; + dataFile_ = nullptr; } void DataProcessor::SetupFileWriter(const bool filewriteEnable, const fileFormat fileFormatType, @@ -231,13 +223,11 @@ std::string DataProcessor::CreateMasterFile( void DataProcessor::ThreadExecution() { char *buffer = nullptr; fifo_->PopAddress(buffer); - LOG(logDEBUG5) << "DataProcessor " << index - << ", " - "pop 0x" - << std::hex << (void *)(buffer) << std::dec << ":" << buffer; + LOG(logDEBUG5) << "DataProcessor " << index << ", " << std::hex + << static_cast(buffer) << std::dec << ":" << buffer; // check dummy - auto numBytes = (uint32_t)(*((uint32_t *)buffer)); + auto numBytes = *reinterpret_cast(buffer); LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes; if (numBytes == DUMMY_PACKET_VALUE) { StopProcessing(buffer); @@ -282,7 +272,7 @@ void DataProcessor::StopProcessing(char *buf) { uint64_t DataProcessor::ProcessAnImage(char *buf) { - auto *rheader = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES); + auto *rheader = reinterpret_cast(buf + FIFO_HEADER_NUMBYTES); sls_detector_header header = rheader->detHeader; uint64_t fnum = header.frameNumber; currentFrameIndex_ = fnum; @@ -316,7 +306,7 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) { try { // normal call back if (rawDataReadyCallBack != nullptr) { - std::size_t dsize = *reinterpret_cast(buf); + std::size_t dsize = *reinterpret_cast(buf); rawDataReadyCallBack(rheader, buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), @@ -325,7 +315,7 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) { // call back with modified size else if (rawDataModifyReadyCallBack != nullptr) { - std::size_t revsize = *reinterpret_cast(buf); + std::size_t revsize = *reinterpret_cast(buf); rawDataModifyReadyCallBack(rheader, buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), @@ -370,14 +360,15 @@ bool DataProcessor::CheckTimer() { struct timespec end; clock_gettime(CLOCK_REALTIME, &end); - LOG(logDEBUG1) << index << " Timer elapsed time:" - << ((end.tv_sec - timerbegin_.tv_sec) + - (end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0) + auto elapsed_s = (end.tv_sec - timerbegin_.tv_sec) + + (end.tv_nsec - timerbegin_.tv_nsec) / 1e9; + double timer_s = *streamingTimerInMs_ / 1e3; + + LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s << " seconds"; + // still less than streaming timer, keep waiting - if (((end.tv_sec - timerbegin_.tv_sec) + - (end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0) < - ((double)*streamingTimerInMs_ / 1000.00)) + if (elapsed_s < timer_s) return false; // restart timer @@ -410,7 +401,8 @@ void DataProcessor::PadMissingPackets(char *buf) { LOG(logDEBUG) << index << ": Padding Missing Packets"; uint32_t pperFrame = generalData_->packetsPerFrame; - auto *header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES); + auto *header = + reinterpret_cast(buf + FIFO_HEADER_NUMBYTES); uint32_t nmissing = pperFrame - header->detHeader.packetNumber; sls_bitset pmask = header->packetsMask; @@ -483,7 +475,7 @@ void DataProcessor::RearrangeDbitData(char *buf) { // ceil as numResult8Bits could be decimal const int numResult8Bits = - ceil((double)(numSamples * (*ctbDbitList_).size()) / 8.00); + ceil((numSamples * (*ctbDbitList_).size()) / 8.00); std::vector result(numResult8Bits); uint8_t *dest = &result[0]; @@ -499,7 +491,7 @@ void DataProcessor::RearrangeDbitData(char *buf) { } // loop through the frame digital data - for (auto ptr = source; ptr < (source + numSamples);) { + for (auto *ptr = source; ptr < (source + numSamples);) { // get selected bit from each 8 bit uint8_t bit = (*ptr++ >> bi) & 1; *dest |= bit << bitoffset; diff --git a/slsReceiverSoftware/src/DataProcessor.h b/slsReceiverSoftware/src/DataProcessor.h index 9756b6896..69cc0a33b 100644 --- a/slsReceiverSoftware/src/DataProcessor.h +++ b/slsReceiverSoftware/src/DataProcessor.h @@ -155,7 +155,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject { uint32_t *streamingTimerInMs_; uint32_t *streamingStartFnum_; uint32_t currentFreqCount_{0}; - struct timespec timerbegin_; + struct timespec timerbegin_{}; bool *framePadding_; std::vector *ctbDbitList_; int *ctbDbitOffset_;