[U-Boot-Users] [PATCH V2] Fix Ethernet init() return codes.

Ulf Samuelsson ulf at atmel.com
Thu Jan 10 01:11:49 CET 2008



> In message <014701c852ed$4b0c4040$6103170a at atmel.com> you wrote:
>>
>> Why not use symbolic return values?
> 
> Because then nobody knows what the symbols mean.
> 
>> "return SUCCESS;" seems much more appropriate than 
>> "return 0;"  or "return -1;"
> 
> These constants are unmistakeable for anyone who ever wrote a program
> under any Unix system...
> 
>> if(myfunction() == SUCCESS) {
>> 
>> }
>> 
>> is much more clear than 
>> 
>> if(myfunction()) {
>> 
>> }
> 
> Not to me. The former needs a lookup of the define, the latter is
> obvious.
>

In properly structured programs, the representation of an enumeration variable is irrelevant.
I.E: You do not need to lookup the value of SUCCESS, (but you do need to know that
the return value "SUCCESS" means that the call did not fail).

You have the power to ack/nack patches, I am sure you are capable of nack'ing
patches which return SUCCESS when the call fails.

Obviously code like

"if (myfunction() > SUCCESS)"
is not going to be acceptable, but that should probably be
replaced by 

"if (myfunction() != SUCCESS)"

 
Best regards,
Ulf Samuelsson




More information about the U-Boot mailing list