thesofproject / rimage

DSP firmware image creation and signing tool
Other
7 stars 62 forks source link

config: Adjust return type with function name #61

Closed ktrzcinx closed 3 years ago

ktrzcinx commented 3 years ago

Function with parse_uint32 should return uint32_t value

Signed-off-by: Karol Trzcinski karolx.trzcinski@intel.com

ktrzcinx commented 3 years ago

I guess the function always succeeds??

No, it can fail. For checking this, there is error parameter.

paulstelian97 commented 3 years ago

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)

ktrzcinx commented 3 years ago

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.