Vladislav Vaintroub wrote:
>
>> -----Original Message-----
>> From: Mats.Kindahl@stripped [mailto:Mats.Kindahl@stripped] On Behalf Of
>> Mats Kindahl
>> Sent: Monday, October 19, 2009 1:47 PM
>> To: Ingo Strüwing
>> Cc: MARK CALLAGHAN; MySQL Internal
>> Subject: Re: Coding style changes of 2009-06-26 now in the guidelines
>>
>>
>>
>> Ingo Strüwing wrote:
>>> Hi Mark,
>>>
>>> MARK CALLAGHAN, 17.10.2009 20:31:
>>>
>>> ...
>>>> * Functions should return zero on success, and non-zero on
>> error,
>>>> so you can do:
>>>>
>>>> Can this be extended to state that these functions should return int
>>>> rather than bool/my_bool? Some functions today use bool/my_bool and
>>>> return TRUE on error. I have to read the code for these to figure
>> out
>>>> whether TRUE is returned on error.
>>> thanks for the suggestion. Is this a formal request to the MySQL
>> Server
>>> coding style government committee?
>>>
>>>
>> http://forge.mysql.com/wiki/MySQL_Internals_Coding_Guidelines#How_we_ma
>> intain_the_server_coding_guidelines
>>> In this case, please add, what the implementation strategy should be:
>>> Change all existing code, or let only new code follow the proposal.
>> If Mark does not submit it, I do.
>
> As for me, I can get along with following conventions and with the mix of
> them:
> 1) Unix OS conventions (function returns int , success is 0, error is -1,
> error details in errno)
> 2) Windows OS conventions (function returns BOOL, success is TRUE, error is
> FALSE, error details in GetLastError())
>
> I cannot get along with a convention "function returns my_bool, success is
> TRUE, error is FALSE", it looks weird to me, violating the 2)
Yes, I also think that it is strange to have the "error convention" with a
return value of my_bool.
I would prefer to have it as you suggest in the first alternative with the
exception that I would like to have 0 as "No Error" and anything else as an
error code. This is how it works in the code now, and the errno approach have
proven to be problematic for multi-threaded code, so I would like to avoid that
as far as possible.
Best wishes,
Mats Kindahl
--
Mats Kindahl
Senior Software Engineer
Database Technology Group
Sun Microsystems