GeezerVison is showing github.com — Algorithm Common: add braces to single statements (#4567) · coppedis/AliceO2@b7bb4e9
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Algorithm/include/Algorithm/Parser.h +25-12Lines changed: 25 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -158,25 +158,30 @@ class ForwardParser | 158 | 158 | { | 159 | 159 | static_assert(sizeof(InputType) == 1, | 160 | 160 | "ForwardParser currently only supports byte type buffer"); | 161 | | - if (buffer == nullptr || bufferSize == 0) | | 161 | + if (buffer == nullptr || bufferSize == 0) { | 162 | 162 | return 0; | | 163 | + } | | 164 | + | 163 | 165 | size_t position = 0; | 164 | 166 | std::vector<FrameInfo> frames; | 165 | 167 | do { | 166 | 168 | FrameInfo entry; | 167 | 169 |
| 168 | 170 | // check the header | 169 | | - if (sizeof(HeaderType) + position > bufferSize) | | 171 | + if (sizeof(HeaderType) + position > bufferSize) { | 170 | 172 | break; | | 173 | + } | 171 | 174 | entry.header = reinterpret_cast<const HeaderType*>(buffer + position); | 172 | | - if (!checkHeader(*entry.header)) | | 175 | + if (!checkHeader(*entry.header)) { | 173 | 176 | break; | | 177 | + } | 174 | 178 |
| 175 | 179 | // extract frame size from header, this is expected to be the | 176 | 180 | // total frome size including header, payload and optional trailer | 177 | 181 | auto frameSize = getFrameSize(*entry.header); | 178 | | - if (frameSize + position > bufferSize) | | 182 | + if (frameSize + position > bufferSize) { | 179 | 183 | break; | | 184 | + } | 180 | 185 |
| 181 | 186 | // payload starts right after the header | 182 | 187 | entry.payload = reinterpret_cast<typename FrameInfo::PtrT>(entry.header + 1); | @@ -188,8 +193,9 @@ class ForwardParser | 188 | 193 | } else { | 189 | 194 | auto trailerStart = buffer + position + frameSize - tailOffset; | 190 | 195 | entry.trailer = reinterpret_cast<const TrailerType*>(trailerStart); | 191 | | - if (!CheckTrailer(entry, checkTrailer)) | | 196 | + if (!CheckTrailer(entry, checkTrailer)) { | 192 | 197 | break; | | 198 | + } | 193 | 199 | } | 194 | 200 |
| 195 | 201 | // store the extracted frame info and continue with remaining buffer | @@ -201,8 +207,9 @@ class ForwardParser | 201 | 207 | // frames found and format consistent, insert entries to target | 202 | 208 | // Note: the complete block must be consistent | 203 | 209 | for (auto entry : frames) { | 204 | | - if (!insert(entry)) | | 210 | + if (!insert(entry)) { | 205 | 211 | break; | | 212 | + } | 206 | 213 | } | 207 | 214 | return frames.size(); | 208 | 215 | } else if (frames.size() == 0) { | @@ -332,30 +339,35 @@ class ReverseParser | 332 | 339 | { | 333 | 340 | static_assert(sizeof(InputType) == 1, | 334 | 341 | "ReverseParser currently only supports byte type buffer"); | 335 | | - if (buffer == nullptr || bufferSize == 0) | | 342 | + if (buffer == nullptr || bufferSize == 0) { | 336 | 343 | return 0; | | 344 | + } | 337 | 345 | auto position = bufferSize; | 338 | 346 | std::vector<FrameInfo> frames; | 339 | 347 | do { | 340 | 348 | FrameInfo entry; | 341 | 349 |
| 342 | 350 | // start from end, extract and check trailer | 343 | | - if (sizeof(TrailerType) > position) | | 351 | + if (sizeof(TrailerType) > position) { | 344 | 352 | break; | | 353 | + } | 345 | 354 | entry.trailer = reinterpret_cast<const TrailerType*>(buffer + position - sizeof(TrailerType)); | 346 | | - if (!checkTrailer(*entry.trailer)) | | 355 | + if (!checkTrailer(*entry.trailer)) { | 347 | 356 | break; | | 357 | + } | 348 | 358 |
| 349 | 359 | // get the total frame size | 350 | 360 | auto frameSize = getFrameSize(*entry.trailer); | 351 | | - if (frameSize > position) | | 361 | + if (frameSize > position) { | 352 | 362 | break; | | 363 | + } | 353 | 364 |
| 354 | 365 | // extract and check header | 355 | 366 | auto headerStart = buffer + position - frameSize; | 356 | 367 | entry.header = reinterpret_cast<const HeaderType*>(headerStart); | 357 | | - if (!checkHeader(*entry.header)) | | 368 | + if (!checkHeader(*entry.header)) { | 358 | 369 | break; | | 370 | + } | 359 | 371 |
| 360 | 372 | // payload immediately after header | 361 | 373 | entry.payload = reinterpret_cast<typename FrameInfo::PtrT>(entry.header + 1); | @@ -367,8 +379,9 @@ class ReverseParser | 367 | 379 | if (position == 0) { | 368 | 380 | // frames found and format consistent, the complete block must be consistent | 369 | 381 | for (auto entry : frames) { | 370 | | - if (!insert(entry)) | | 382 | + if (!insert(entry)) { | 371 | 383 | break; | | 384 | + } | 372 | 385 | } | 373 | 386 | return frames.size(); | 374 | 387 | } else if (frames.size() == 0) { | |
Collapse file Copy file name to clipboardExpand all lines: Algorithm/include/Algorithm/TableView.h +20-10Lines changed: 20 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -67,10 +67,12 @@ class TableView | 67 | 67 |
| 68 | 68 | bool operator<(const FrameIndex& rh) const | 69 | 69 | { | 70 | | - if (rh.columnIndex < columnIndex) | | 70 | + if (rh.columnIndex < columnIndex) { | 71 | 71 | return false; | 72 | | - if (columnIndex < rh.columnIndex) | | 72 | + } | | 73 | + if (columnIndex < rh.columnIndex) { | 73 | 74 | return true; | | 75 | + } | 74 | 76 | return row < rh.row; | 75 | 77 | } | 76 | 78 | }; | @@ -143,8 +145,9 @@ class TableView | 143 | 145 | /// get row data for a data set | 144 | 146 | const RowDescType& getRowData(size_t row) const | 145 | 147 | { | 146 | | - if (row < mRowData.size()) | | 148 | + if (row < mRowData.size()) { | 147 | 149 | return mRowData[row]; | | 150 | + } | 148 | 151 | // TODO: better to throw exception? | 149 | 152 | static RowDescType dummy; | 150 | 153 | return dummy; | @@ -180,22 +183,26 @@ class TableView | 180 | 183 | iterator(IteratorDirections direction, TableView* parent, unsigned row = 0, unsigned column = 0) | 181 | 184 | : mDirection(direction), mRow(row), mColumn(column), mEnd(direction == kAlongRow ? parent->getNColumns() : parent->getNRows()), mParent(parent), mCache(), mIsCached(false) | 182 | 185 | { | 183 | | - while (!isValid() && !isEnd()) | | 186 | + while (!isValid() && !isEnd()) { | 184 | 187 | operator++(); | | 188 | + } | 185 | 189 | } | 186 | 190 |
| 187 | 191 | self_type& operator++() | 188 | 192 | { | 189 | 193 | mIsCached = false; | 190 | 194 | if (mDirection == kAlongRow) { | 191 | | - if (mColumn < mEnd) | | 195 | + if (mColumn < mEnd) { | 192 | 196 | mColumn++; | | 197 | + } | 193 | 198 | } else { | 194 | | - if (mRow < mEnd) | | 199 | + if (mRow < mEnd) { | 195 | 200 | mRow++; | | 201 | + } | 196 | 202 | } | 197 | | - while (!isEnd() && !isValid()) | | 203 | + while (!isEnd() && !isValid()) { | 198 | 204 | operator++(); | | 205 | + } | 199 | 206 | return *this; | 200 | 207 | } | 201 | 208 |
| @@ -265,11 +272,13 @@ class TableView | 265 | 272 | self_type& operator++() | 266 | 273 | { | 267 | 274 | if (base::mDirection == iterator::kAlongRow) { | 268 | | - if (base::mColumn < base::mEnd) | | 275 | + if (base::mColumn < base::mEnd) { | 269 | 276 | base::mColumn++; | | 277 | + } | 270 | 278 | } else { | 271 | | - if (base::mRow < base::mEnd) | | 279 | + if (base::mRow < base::mEnd) { | 272 | 280 | base::mRow++; | | 281 | + } | 273 | 282 | } | 274 | 283 | return *this; | 275 | 284 | } | @@ -314,8 +323,9 @@ class TableView | 314 | 323 | /// private access function for the iterators | 315 | 324 | bool get(unsigned row, unsigned column, FrameData& data) | 316 | 325 | { | 317 | | - if (this->mColumns.size() == 0) | | 326 | + if (this->mColumns.size() == 0) { | 318 | 327 | return false; | | 328 | + } | 319 | 329 | auto element = this->mFrames.find(FrameIndex{this->mColumns[column], row}); | 320 | 330 | if (element != this->mFrames.end()) { | 321 | 331 | data = element->second; | |
Collapse file Copy file name to clipboardExpand all lines: Algorithm/test/pageparser.cxx +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -78,8 +78,9 @@ std::pair<std::unique_ptr<uint8_t[]>, size_t> MakeBuffer(size_t pagesize, | 78 | 78 | } while (nPages * pagesize < totalSize); | 79 | 79 | } else { | 80 | 80 | auto nRequiredPages = dataset.size() / maxElementsPerPage; | 81 | | - if (dataset.size() % maxElementsPerPage > 0) | | 81 | + if (dataset.size() % maxElementsPerPage > 0) { | 82 | 82 | ++nRequiredPages; | | 83 | + } | 83 | 84 | totalSize = (nRequiredPages > 0 ? nRequiredPages : 1) * pagesize; | 84 | 85 | } | 85 | 86 |
| |
Collapse file Copy file name to clipboardExpand all lines: CCDB/include/CCDB/BasicCCDBManager.h +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -147,8 +147,9 @@ T* BasicCCDBManager::getForTimeStamp(std::string const& path, long timestamp) | 147 | 147 | mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : ""); | 148 | 148 | } | 149 | 149 | auto& cached = mCache[path]; | 150 | | - if (mCheckObjValidityEnabled && cached.isValid(timestamp)) | | 150 | + if (mCheckObjValidityEnabled && cached.isValid(timestamp)) { | 151 | 151 | return reinterpret_cast<T*>(cached.objPtr.get()); | | 152 | + } | 152 | 153 |
| 153 | 154 | T* ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, &mHeaders, cached.uuid, | 154 | 155 | mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "", | |
Collapse file Copy file name to clipboardExpand all lines: Common/Field/src/MagFieldFast.cxx +16-9Lines changed: 16 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -68,22 +68,25 @@ bool MagFieldFast::LoadData(const string inpFName) | 68 | 68 | SolParam* curParam = nullptr; | 69 | 69 |
| 70 | 70 | while (std::getline(in, line)) { | 71 | | - if (line.empty() || line[0] == '#') | | 71 | + if (line.empty() || line[0] == '#') { | 72 | 72 | continue; // empy or comment | | 73 | + } | 73 | 74 | std::stringstream ss(line); | 74 | 75 | int cnt = 0; | 75 | 76 |
| 76 | 77 | if (component < 0) { | 77 | | - while (cnt < 4 && (ss >> header[cnt++])) | | 78 | + while (cnt < 4 && (ss >> header[cnt++])) { | 78 | 79 | ; | | 80 | + } | 79 | 81 | if (cnt != 4) { | 80 | 82 | LOG(FATAL) << "Wrong header " << line; | 81 | 83 | return false; | 82 | 84 | } | 83 | 85 | curParam = &mSolPar[header[0]][header[1]][header[2]]; | 84 | 86 | } else { | 85 | | - while (cnt < header[3] && (ss >> curParam->parBxyz[component][cnt++])) | | 87 | + while (cnt < header[3] && (ss >> curParam->parBxyz[component][cnt++])) { | 86 | 88 | ; | | 89 | + } | 87 | 90 | if (cnt != header[3]) { | 88 | 91 | LOG(FATAL) << "Wrong data (npar=" << cnt << ") for param " << header[0] << " " << header[1] << " " << header[2] | 89 | 92 | << " " << header[3] << " " << line; | @@ -215,20 +218,24 @@ bool MagFieldFast::GetSegment(float x, float y, float z, int& zSeg, int& rSeg, i | 215 | 218 | const float zGridSpaceInv = 1.f / (kSolZMax * 2 / kNSolZRanges); | 216 | 219 | zSeg = -1; | 217 | 220 | if (z < kSolZMax) { | 218 | | - if (z > -kSolZMax) | | 221 | + if (z > -kSolZMax) { | 219 | 222 | zSeg = (z + kSolZMax) * zGridSpaceInv; // solenoid params | 220 | | - else { // need to check dipole params | | 223 | + } else { // need to check dipole params | 221 | 224 | return false; | 222 | 225 | } | 223 | | - } else | | 226 | + } else { | 224 | 227 | return false; | | 228 | + } | 225 | 229 | // R segment | 226 | 230 | float xx = x * x, yy = y * y, rr = xx + yy; | 227 | | - for (rSeg = 0; rSeg < kNSolRRanges; rSeg++) | 228 | | - if (rr < kSolR2Max[rSeg]) | | 231 | + for (rSeg = 0; rSeg < kNSolRRanges; rSeg++) { | | 232 | + if (rr < kSolR2Max[rSeg]) { | 229 | 233 | break; | 230 | | - if (rSeg == kNSolRRanges) | | 234 | + } | | 235 | + } | | 236 | + if (rSeg == kNSolRRanges) { | 231 | 237 | return kFALSE; | | 238 | + } | 232 | 239 | quadrant = GetQuadrant(x, y); | 233 | 240 | return true; | 234 | 241 | } |
Collapse file Copy file name to clipboardExpand all lines: Common/Field/src/MagFieldParam.cxx +20-10Lines changed: 20 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -48,8 +48,9 @@ void MagFieldParam::SetParam(const MagneticField* field) | 48 | 48 | void MagFieldParam::putParams(FairParamList* list) | 49 | 49 | { | 50 | 50 | /// store parameters in the list | 51 | | - if (!list) | | 51 | + if (!list) { | 52 | 52 | return; | | 53 | + } | 53 | 54 | list->add("Map Type ID", int(mMapType)); | 54 | 55 | list->add("Beam Type ID", int(mBeamType)); | 55 | 56 | list->add("Integral Type", mDefaultIntegration); | @@ -65,33 +66,42 @@ Bool_t MagFieldParam::getParams(FairParamList* list) | 65 | 66 | { | 66 | 67 | /// retried parameters | 67 | 68 | int int2enum = 0; | 68 | | - if (!list->fill("Map Type ID", &int2enum)) | | 69 | + if (!list->fill("Map Type ID", &int2enum)) { | 69 | 70 | return kFALSE; | | 71 | + } | 70 | 72 | mMapType = static_cast<BMap_t>(int2enum); | 71 | | - if (!list->fill("Beam Type ID", &int2enum)) | | 73 | + if (!list->fill("Beam Type ID", &int2enum)) { | 72 | 74 | return kFALSE; | | 75 | + } | 73 | 76 | mBeamType = static_cast<BeamType_t>(int2enum); | 74 | 77 | // | 75 | | - if (!list->fill("Integral Type", &mDefaultIntegration)) | | 78 | + if (!list->fill("Integral Type", &mDefaultIntegration)) { | 76 | 79 | return kFALSE; | 77 | | - if (!list->fill("Fact.Solenoid", &mFactorSol)) | | 80 | + } | | 81 | + if (!list->fill("Fact.Solenoid", &mFactorSol)) { | 78 | 82 | return kFALSE; | 79 | | - if (!list->fill("Fact.Dipole ", &mFactorDip)) | | 83 | + } | | 84 | + if (!list->fill("Fact.Dipole ", &mFactorDip)) { | 80 | 85 | return kFALSE; | 81 | | - if (!list->fill("Beam Energy ", &mBeamEnergy)) | | 86 | + } | | 87 | + if (!list->fill("Beam Energy ", &mBeamEnergy)) { | 82 | 88 | return kFALSE; | 83 | | - if (!list->fill("Max. Field ", &mMaxField)) | | 89 | + } | | 90 | + if (!list->fill("Max. Field ", &mMaxField)) { | 84 | 91 | return kFALSE; | | 92 | + } | 85 | 93 | FairParamObj* parpath = list->find("Path to map "); | 86 | | - if (!parpath) | | 94 | + if (!parpath) { | 87 | 95 | return kFALSE; | | 96 | + } | 88 | 97 | int lgt = parpath->getLength(); | 89 | 98 | // RS: is there a bug in FairParamList::fill(const Text_t* name,Text_t* value,const Int_t length)? | 90 | 99 | // I think the "if (l<length-1)" should be "if (l<length)" | 91 | 100 | char cbuff[lgt + 2]; | 92 | 101 | memset(cbuff, 0, sizeof(char) * (lgt + 2)); | 93 | | - if (!list->fill("Path to map ", cbuff, lgt + 2)) | | 102 | + if (!list->fill("Path to map ", cbuff, lgt + 2)) { | 94 | 103 | return kFALSE; | | 104 | + } | 95 | 105 | mMapPath = cbuff; | 96 | 106 | return kTRUE; | 97 | 107 | } |
|