robotology / yarp-device-xsensmt

YARP Device Driver for XSens MT* devices based on the MT Software Suite.
Other
5 stars 5 forks source link

Warning in legacydatapacket.cpp file provided by Xsens #21

Open traversaro opened 4 years ago

traversaro commented 4 years ago

Compiling the code with a recent compiler, I got this warning in Xsens provided code:

/home/straversaro/src/robotology-superbuild/robotology/xsensmt-yarp-driver/extern/xcommunication/legacydatapacket.cpp: In member function ‘bool LegacyDataPacket::setRawTemperature(uint16_t, int32_t, int)’:
/home/straversaro/src/robotology-superbuild/robotology/xsensmt-yarp-driver/extern/xcommunication/legacydatapacket.cpp:1030:53: warning: iteration 3 invokes undefined behavior [-Waggressive-loop-optimizations]
     m_fixedData->m_infoList[index].m_rawGyroTemp[i] = (uint16_t) m_msg.getDataSize();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/straversaro/src/robotology-superbuild/robotology/xsensmt-yarp-driver/extern/xcommunication/legacydatapacket.cpp:1028:21: note: within this loop
    for(int i = 0; i <= XS_EXTRA_TEMPERATURE_CHANNELS; ++i)
                     ^
/home/straversaro/src/robotology-superbuild/robotology/xsensmt-yarp-driver/extern/xcommunication/legacydatapacket.cpp: In member function ‘bool LegacyDataPacket::setTemperature(double, int32_t, int)’:
/home/straversaro/src/robotology-superbuild/robotology/xsensmt-yarp-driver/extern/xcommunication/legacydatapacket.cpp:1407:50: warning: iteration 3 invokes undefined behavior [-Waggressive-loop-optimizations]
     m_fixedData->m_infoList[index].m_gyroTemp[i] = (uint16_t) m_msg.getDataSize();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/straversaro/src/robotology-superbuild/robotology/xsensmt-yarp-driver/extern/xcommunication/legacydatapacket.cpp:1405:21: note: within this loop
    for(int i = 0; i <= XS_EXTRA_TEMPERATURE_CHANNELS; ++i)
                     ^

It is possible that this issue is solved in a more recent version of the Xsens software, see https://github.com/robotology/xsensmt-yarp-driver/pull/9 for a similar update in the past.