Closed ktrzcinx closed 3 years ago
I guess the function always succeeds??
No, it can fail. For checking this, there is error
parameter.
A bit dubious but I guess we shouldn't make more important changes (I'm more used to having errors directly returned and results returned via pointer, rather than the converse, when both cannot be returned in a single value)
I'm more used to having errors directly returned and results returned via pointer
Me too, here the issue was a direct writing to different data types in structs, like uint8_t, uint16_t, or some enums without a risk of unintended modifying following fields in case of fields size mismatch. In solution like this, the result may be easily casted to different data type.
Moreover, such a way of returning error code, force developer to define error
variable - otherwise code just won't compile. In the result it's less likely to just forget about error checking.
Function with
parse_uint32
should return uint32_t valueSigned-off-by: Karol Trzcinski karolx.trzcinski@intel.com