1
0
Fork 0

Reduce scope of local variables to avoid warning about shadowing

After adding -Wshadow to build options, gcc produced following warning:

305/CO_LSSslave.c: In function ‘CO_LSSslave_receive’:
305/CO_LSSslave.c:114:30: warning: declaration of ‘valSw’ shadows a
previous local [-Wshadow]
  114 |                     uint32_t valSw;
      |                              ^~~~~
305/CO_LSSslave.c:76:22: note: shadowed declaration is here
   76 |             uint32_t valSw;
      |                      ^~~~~
This commit is contained in:
Freddie Chopin 2020-10-24 14:46:34 +02:00
parent 2c9d07f265
commit ddc2443cfd

View file

@ -73,24 +73,27 @@ static void CO_LSSslave_receive(void *object, void *msg)
}
}
else if(LSSslave->lssState == CO_LSS_STATE_WAITING) {
uint32_t valSw;
switch (cs) {
case CO_LSS_SWITCH_STATE_SEL_VENDOR: {
uint32_t valSw;
memcpy(&valSw, &data[1], sizeof(valSw));
LSSslave->lssSelect.identity.vendorID = CO_SWAP_32(valSw);
break;
}
case CO_LSS_SWITCH_STATE_SEL_PRODUCT: {
uint32_t valSw;
memcpy(&valSw, &data[1], sizeof(valSw));
LSSslave->lssSelect.identity.productCode = CO_SWAP_32(valSw);
break;
}
case CO_LSS_SWITCH_STATE_SEL_REV: {
uint32_t valSw;
memcpy(&valSw, &data[1], sizeof(valSw));
LSSslave->lssSelect.identity.revisionNumber = CO_SWAP_32(valSw);
break;
}
case CO_LSS_SWITCH_STATE_SEL_SERIAL: {
uint32_t valSw;
memcpy(&valSw, &data[1], sizeof(valSw));
LSSslave->lssSelect.identity.serialNumber = CO_SWAP_32(valSw);