Subject: Re: breaking the ABI (was Re: 'watch' libssh2 on github)

Re: breaking the ABI (was Re: 'watch' libssh2 on github)

From: Alexander Lamaison <swish_at_lammy.co.uk>
Date: Fri, 13 Mar 2015 17:47:18 +0000

On 13 Mar 2015 16:46, "Alexander Lamaison" <swish_at_lammy.co.uk> wrote:
>
> On 13 Mar 2015 16:18, "Will Cosgrove" <will_at_panic.com> wrote:
> >>
> >> >> we have a function like errorMessageFromCode(int code), the _code_
is the code coming from any o’l libssh function call.
> >> >
> >> >
> >> > But that's the mistake. All libssh2 functions don't return the same
error code set. The libssh2_knownhost*() functions for example only return
error codes in the LIBSSH2_KNOWNHOST_CHECK_* series.
> >>
> >> If I may weigh in here, the known_host return codes aren't error codes
at all. That's where the misunderstanding has occurred.
> >>
> >> Most libssh2 return codes are indeed errors. You can think of them as
exceptions, in a language that has that feature. Apart from EAGAIN, you
never call a libssh2 function expecting to recieve one of those errors.
> >>
> >> Contrast that with the known_host functions. There the return code is
a result, not an error. You call those functions fully expecting to get any
of the possible values returned.
> >
> > I understand these are technically not errors per-say, but that doesn’t
mean I agree with their values being the same.
>
> Would you feel different if the function did a calculation that returned
a number? Or checked something and returned a boolean?
>
> Both those would return values that overlapped with the error codes. But
they aren't error codes, so you presumably wouldn't care. The known_hosts
functions are no different.

I've thought about this some more and I think I understand where the
confusion arises. You are understandably assuming that
libssh2_knownhost_check returns error codes when it hits an error (a real,
unexpected, exception-type failure; not just 'not found'). It doesn't. It
actually return there result FAILURE which means you should call
libssh2_session_last_errno function to get the real error code (for example
LIBSSH2_ERROR_ALLOC).

Alex

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2015-03-13