diff --git a/src/OutputByOrbit.cc b/src/OutputByOrbit.cc index e286bf0267bc359362ce78c8561c677893dbbf20..1d26c46642f6a4b7708f3907c287aa6747dfa982 100644 --- a/src/OutputByOrbit.cc +++ b/src/OutputByOrbit.cc @@ -24,7 +24,7 @@ OutputByOrbitStream::OutputByOrbitStream(ctrl &ctrl, config &conf) void OutputByOrbitStream::OutputFixedOrbits(Slice &out) { uint32_t orbitN = out.get_firstOrbitN(); - uint32_t index = uint32_t(orbitN / conf_.getNOrbitsPerFile()); + auto index = uint32_t(orbitN / conf_.getNOrbitsPerFile()); size_t n = 0; if ((out.get_counts() != 0) || conf_.getCMSSWHeaders()) { diff --git a/src/processor.cc b/src/processor.cc index b0cfaac2e91fd0be709c281bbb491d598ca10c86..1177c8ca8fbbfc2aa9eb2b7d5a2c9d6209cee69a 100644 --- a/src/processor.cc +++ b/src/processor.cc @@ -75,7 +75,7 @@ bool StreamProcessor::CheckFrameMultBlock(size_t inputSize) { bool StreamProcessor::GetTrailer(Slice &input, char *&rd_ptr) { rd_ptr += 32; // +32 to account for orbit header while (rd_ptr + sizeof(orbit_trailer) - 1 <= input.end()) { - orbit_trailer *ot = reinterpret_cast<orbit_trailer *>(rd_ptr); + auto *ot = reinterpret_cast<orbit_trailer *>(rd_ptr); if (ot->beefdead[0] == constants::beefdead) { // found orbit trailer return true; } @@ -86,9 +86,9 @@ bool StreamProcessor::GetTrailer(Slice &input, char *&rd_ptr) { inline std::pair<uint32_t, bool> StreamProcessor::ProcessOrbitHeader(char *rd_ptr) { // get orbit from orbit header - blockMuon *bl_pre = + auto *bl_pre = reinterpret_cast<blockMuon *>(rd_ptr); // blockMuon.orbit is identical to blockCalo.frame0 - uint32_t orbitN = uint32_t{bl_pre->orbit[0]}; + auto orbitN = uint32_t{bl_pre->orbit[0]}; // save warning_test_enable bit bool warning_test_enable = bool{(orbitN & (1 << 31)) == (1 << 31)}; // remove warning_test_enable bit from orbit header @@ -113,7 +113,7 @@ StreamProcessor::fillOrbitMetadata StreamProcessor::FillOrbitCalo(orbit_trailer uint32_t orbit = uint32_t{orbit_header.first} - 1; // Starting with orbit number one lower than what is in the header // because the "link orbit" contains a few BXs of the previous orbit - uint32_t counts = uint32_t{0}; + auto counts = uint32_t{0}; uint32_t filled_bxs = 0; // We loop over the BX map from the orbit trailer and then match the filled // BXs to the data we got. The logic below is annoyingly convoluted: The first @@ -146,12 +146,12 @@ StreamProcessor::fillOrbitMetadata StreamProcessor::FillOrbitCalo(orbit_trailer } assert(rd_ptr + sizeof(blockCalo) - 1 <= rd_end_ptr); ++filled_bxs; - blockCalo *bl = reinterpret_cast<blockCalo *>(rd_ptr); + auto *bl = reinterpret_cast<blockCalo *>(rd_ptr); if (bl->calo0[0] == constants::beefdead) { break; } // orbit trailer has been reached, end of orbit data assert(wr_ptr + (3 + 8 * 7) * 4 - 1 <= wr_end_ptr); - uint32_t header = uint32_t{orbit_header.second}; // header can be added to later + auto header = uint32_t{orbit_header.second}; // header can be added to later memcpy(wr_ptr, (char *)&header, 4); wr_ptr += 4; memcpy(wr_ptr, (char *)&bx, 4); @@ -208,7 +208,7 @@ uint32_t StreamProcessor::FillBril(char *rd_ptr, char *wr_ptr, char *end_ptr) { while (rd_ptr != end_ptr) { assert(rd_ptr + sizeof(brilFrame) - 1 <= end_ptr); - brilFrame *fr = reinterpret_cast<brilFrame *>(rd_ptr); + auto *fr = reinterpret_cast<brilFrame *>(rd_ptr); if (fr->counter < constants::NFramesInHistoHeader) { if (fr->counter == 5) { // add run number, 6th frame in bril header is run number @@ -249,7 +249,7 @@ StreamProcessor::fillOrbitMetadata StreamProcessor::FillOrbitMuon(orbit_trailer uint32_t orbit = uint32_t{orbit_header.first} - 1; // Starting with orbit number one lower than what is in the header // because the "link orbit" contains a few BXs of the previous orbit - uint32_t counts = uint32_t{0}; + auto counts = uint32_t{0}; uint32_t filled_bxs = 0; // We loop over the BX map from the orbit trailer and then match the filled // BXs to the data we got. The logic below is annoyingly convoluted: The first @@ -282,7 +282,7 @@ StreamProcessor::fillOrbitMetadata StreamProcessor::FillOrbitMuon(orbit_trailer } assert(rd_ptr + sizeof(blockMuon) - 1 <= rd_end_ptr); ++filled_bxs; - blockMuon *bl = reinterpret_cast<blockMuon *>(rd_ptr); + auto *bl = reinterpret_cast<blockMuon *>(rd_ptr); if (bl->orbit[0] == constants::beefdead) { break; } // orbit trailer has been reached, end of orbit data @@ -316,7 +316,7 @@ StreamProcessor::fillOrbitMetadata StreamProcessor::FillOrbitMuon(orbit_trailer // header word of packed muon data contains mAcount (number of muons in // words 3,4) and mBcount (number of muons in words 5,5), as well as the // warning test enaable flag. - uint32_t header = + auto header = uint32_t{(mAcount << 16) + ((static_cast<uint32_t>(orbit_header.second)) << 8) + mBcount}; counts += mAcount; @@ -397,7 +397,7 @@ void StreamProcessor::process(Slice &input, Slice &out) { << stats.orbit_trailer_error_count; return; } - orbit_trailer *trailer = reinterpret_cast<orbit_trailer *>(trailer_ptr); + auto *trailer = reinterpret_cast<orbit_trailer *>(trailer_ptr); size_t additional_header_size = 0; if (processorType == ProcessorType::GMT) { @@ -448,7 +448,7 @@ void StreamProcessor::process(Slice &input, Slice &out) { } if (rd_ptr < input.end()) { - uint32_t *dma_trailer_word = (uint32_t *)(rd_ptr); + auto *dma_trailer_word = (uint32_t *)(rd_ptr); if (*dma_trailer_word == constants::deadbeef) { out.set_end(wr_ptr); out.set_counts(counts); diff --git a/src/tools.h b/src/tools.h index a1734ccad8e7e3b6387ae6c7135f2aa4c04b01a8..c444fa177e73e67ffd9c0b9d9ef34f867f11ccf7 100644 --- a/src/tools.h +++ b/src/tools.h @@ -57,15 +57,15 @@ namespace filesystem { inline bool create_directories(std::string &path) { char tmp[PATH_MAX]; - // Add terminating '/' and make a writtable copy; + // Add terminating '/' and make a writable copy; int len = snprintf(tmp, sizeof(tmp), "%s/", path.c_str()); if (len > PATH_MAX) len = PATH_MAX; char *last_backslash = tmp; for (char *p = tmp; *p; p++) { if (*p == '/') { - // Found a new directory, ignore any subsequent back slashes - int dir_len = p - last_backslash - 1; + // Found a new directory, ignore any subsequent backslashes + auto dir_len = p - last_backslash - 1; if (dir_len > 0) { *p = 0; if (mkdir(tmp, S_IRWXU | S_IRWXG | S_IRWXO) < 0 && (errno != EEXIST)) {