[Date Prev][Date Next] [Chronological] [Thread] [Top]

ber_printf's return type in the C API



Yet Another API Nitpick...

As far as I can tell, ber_printf() usually returns the number of octets
written from the last parameter, or -1 on error.  Implementations that
want to do that reliably will need the return type of ber_printf to be
"signed ber_len_t" (OpenLDAP calls it ber_slen_t) instead of int,
otherwise they can't output objects with more than MAX_INT octets.
(They still can't print objects whose size is in the range
<max(ber_slen_t),max(ber_len_t)], though.)

Personally I don't care, but I imagine it could matter to whoever it was
who insisted that we can't give ber_printf and ber_scanf the same error
return (and return type), because it breaks backwards compatibility.


BTW, ber_printf(ber,"") returns 0 on the implementations I have seen.
This violates the clain "ber_printf() returns ... a positive number if
successful", it should be "nonnegative".  The same goes for the
"positive" error codes in section 9 paragraph 1.

-- 
Hallvard