[redland-dev] Wrong API with certain functions

Dave Beckett dave at dajobe.org
Sat Aug 9 17:57:05 EDT 2014


On 8/5/14, 3:55 AM, Victor Porton wrote:
> 05.08.2014, 05:32, "Dave Beckett" <dave at dajobe.org>:
>> On 8/4/14, 5:58 AM, Victor Porton wrote:
>>>  The API for raptor_iostream_write_bytes() function is wrongly documented. (The function itself is correct, just the documentation is wrong.)
>>>
>>>  There are similar issues also with
>>>
>>>  raptor_iostream_decimal_write()
>>>  raptor_iostream_hexadecimal_write()
>>>
>>>  For the last two functions, it is unclear what should be changed, the functions themselves or their documentation.
>>>
>>>  See my bug report (Raptor 2.0.14) for details:
>>>
>>>  http://bugs.librdf.org/mantis/view.php?id=575
>>>
>>>  Please inform me about these two functions, whether we will change the functions themselves or just the documentation.
>>>
>>>  I need this information to continue writing my Ada binding for Raptor.
>>
>> I replied in the bug:
>>
>> The signatures were originally intended to match fwrite() which returns
>> number of objects. Hence why raptor_filename_iostream_write_bytes() just
>> casts it from fwrite(). Although that is bad since the signature of fwrite()
>> returns a size_t, so write_bytes() should have been defined that way.
>>
>> Since raptor_iostream_decimal_write() and
>> raptor_iostream_hexadecimal_write() both call
>> raptor_filename_iostream_write_bytes() they are at least implemented the
>> same way even if the documentation doesn't match.
> 
> What "are at least implemented the same way" means?

I said it: raptor_iostream_decimal_write() and
raptor_iostream_hexadecimal_write() both return the value from their
internal call to raptor_filename_iostream_write_bytes() so they are at least
consistent with each other, even if they don't match the documentation.

> 
> Should I assume that raptor_iostream_decimal_write() and raptor_iostream_hexadecimal_write() return the number of bytes written? (It seems quite useless for me to receive the number of bytes here.)
> 
>> So I guess I'm considering it a documentation bug but I'm open to suggestions.

You didn't express a preference here so I'm favouring making the return
value be number of bytes written or <0 on failure.  Since number of objects
makes no sense for decila/hexdecimal write.

Dave



More information about the redland-dev mailing list