Skip to content

warning fix in the bmon unpacker

Sergey Gorbunov requested to merge se.gorbunov/cbmroot:warnFixBmon into master

This MR fixes the following compiler warning:

/home/cbmdock/cbmroot/algo/detectors/bmon/Unpack.cxx: In member function 'cbm::algo::bmon::Unpack::resultType cbm::algo::bmon::Unpack::operator()(const uint8_t*, const fles::MicrosliceDescriptor&, uint64_t) const':
/home/cbmdock/cbmroot/algo/detectors/bmon/Unpack.cxx:130:50: warning: '*((void*)& time +8)' may be used uninitialized in this function [-Wmaybe-uninitialized]
     double messageTime  = message.getMsgFullTimeD(time.currentEpochInTs) - elinkPar.fTimeOffset;
                           ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/home/cbmdock/cbmroot/algo/detectors/bmon/Unpack.cxx:27:14: note: '*((void*)& time +8)' was declared here
     TimeSpec time;
              ^~~~

The compiler complains that time.currentEpochInTs field may be used uninitialized. In fact, the code logic is correct because there is a check that ensures the first message is an epoch message. But it is too complicated for the compiler. I rewrote the code to read the first message explicitly as an epoch message. It makes the compiler happy.

Edited by Sergey Gorbunov

Merge request reports