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

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

From: Will Cosgrove <will_at_panic.com>
Date: Fri, 13 Mar 2015 10:56:10 -0700

> > >> 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).
>

There is no confusion. I simply do not like conflicting static defined result values. This scenario is different than returning a bool or a random value, these are defined values, that do not change and overlap. It’s not how I would personally do it, perhaps it’s OK with you, that’s OK, we can agree to disagree.

Will

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