Inconsistent variable initialization
kaysievers opened this issue · comments
Kay Sievers commented
Here is a 32bit signed integer field:
typedef struct
{
uint8_t address;
int32_t value;
} TMCRegisterConstant;
Which gets several values assigned that do not fit into this data type:
{ 0x60, 0xAAAAB554 }, // MSLUT[0]
...
{ 0x64, 0xFBFFFFFF }, // MSLUT[4]
{ 0x65, 0xB5BB777D }, // MSLUT[5]
...
The compiler rightfully complains about this:
TMC2130.h:92:1: error: narrowing conversion of '2863314260' from 'unsigned int' to 'int32_t' {aka 'long int'} [-Wnarrowing]
92 | };
Could the field be changed to unsigned, or a cast added to the initializer value to avoid this?
Lenard Heß commented
Fixed in b66f8f2.