vlovich/hidapi — comment on commit ead1eeb99cf87fd281efcdfd4b6feb9d6af4fed5
File:  line 0
By vlovich:

I think there was - I can't recall what it was.

The return value is wrong, since all platforms are inconsistent with the documentation, but it's the same as what was before.

The problem with buf[len - 1] is if the string is shorter than the buffer - you potentially have garbage in your string. This makes sure that you null-terminate at the end of the string. The returned num chars copied is guaranteed not to be out of bounds. There is nothing in the documentation that says that a terminating NULL-character is necessarily written out (& I believe that I verified that there are scenarios where it doesn't).