Union is declared here:
|
typedef union CF_RxTxCounters |
|
{ |
|
unsigned ack; |
|
uint8 nak; |
|
} CF_RxTxCounters_t; |
This counter is then used in the TxS2/RxS2 state data structures.
It should not be necessary to create a union between the unsigned and uint8 types for two reasons:
unsigned is not a known/guaranteed range type, and the rollover point of this value is not guaranteed. FSW discourages use of types which do not have fixed range unless for valid reasons (e.g. interfacing with library code that uses this type)
uint8 is simply the 8 LSBs of the value, there is no need to unionize in order to be able to count both modulo 256 as well as a longer type
In short, declaring a union like this has no benefit at all, but only introduces the possibility of accessing it wrong and getting undefined behavior. Only downsides, no upside.
Recommendation is to replace with a normal uint32 counter.
Union is declared here:
CF/fsw/src/cf_cfdp.h
Lines 137 to 141 in a894069
This counter is then used in the TxS2/RxS2 state data structures.
It should not be necessary to create a union between the
unsignedanduint8types for two reasons:unsignedis not a known/guaranteed range type, and the rollover point of this value is not guaranteed. FSW discourages use of types which do not have fixed range unless for valid reasons (e.g. interfacing with library code that uses this type)uint8is simply the 8 LSBs of the value, there is no need to unionize in order to be able to count both modulo 256 as well as a longer typeIn short, declaring a union like this has no benefit at all, but only introduces the possibility of accessing it wrong and getting undefined behavior. Only downsides, no upside.
Recommendation is to replace with a normal
uint32counter.