Skip to content

Commit

Permalink
ensure bx width of only 12 bits is applied when shifting to avoid UBSAN
Browse files Browse the repository at this point in the history
warning.
  • Loading branch information
smorovic committed Aug 27, 2021
1 parent fd2a236 commit b876620
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DataFormats/FEDRawData/src/FEDHeader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void FEDHeader::set(unsigned char* header,
h->eventid = (FED_SLINK_START_MARKER << FED_HCTRLID_SHIFT) | ((triggerType << FED_EVTY_SHIFT) & FED_EVTY_MASK) |
((lvl1ID << FED_LVL1_SHIFT) & FED_LVL1_MASK);

h->sourceid = ((bxID << FED_BXID_SHIFT) & FED_BXID_MASK) | ((sourceID << FED_SOID_SHIFT) & FED_SOID_MASK) |
((version << FED_VERSION_SHIFT) & FED_VERSION_MASK);
h->sourceid = (((bxID & FED_BXID_WIDTH) << FED_BXID_SHIFT) & FED_BXID_MASK) |
((sourceID << FED_SOID_SHIFT) & FED_SOID_MASK) | ((version << FED_VERSION_SHIFT) & FED_VERSION_MASK);

if (moreHeaders)
h->sourceid |= (FED_MORE_HEADERS_WIDTH << FED_MORE_HEADERS_SHIFT);
Expand Down

0 comments on commit b876620

Please sign in to comment.