[Asterisk-Dev] asterisk functions return codes

Kevin P. Fleming kpfleming at digium.com
Thu Aug 4 07:13:30 MST 2005


Timur V. Elzhov wrote:

> However, when file is non-existent, it returns -1, so the *first*
> condition will be true, and second will be false. So the right way
> I guess is to write
> 
>    if (asterisk_fileexists(...) > 0)

This is basic C understanding; there is no need for an operator here.

> Forgive me if I misunderstand something, but do you really find such
> a behaviour convinient? I find that's not logical, if we have to call
> operators like '<' or '>' when expect answer of only two values, true
> and false.

There is no need for an operator. This also follows the majority of the 
functions in the C library, that return zero for 'success' and non-zero 
for 'failure'.

> So, the main question is, again: Are there a general convention about
> function return codes in the asterisk sources?

Yes, the functions tend to follow the standard C library.



More information about the asterisk-dev mailing list