​That is simply incorrect. It might not be how you would like it to behave,
however it is the norm that short writes are allowed and should be handled by
the callee. This is the case in POSIX, the C standard library etc. I'm afraid,
you'll simply have to learn to live with it - an easy solution would be to write
a tiny wrapper function of your own however if you do you'll need to be very
careful with your error handling if you always want to be able to retry.


I agree with the existing behavior but I, like many users I am sure,
got bitten by this behavior as well. I think this is one of many cases
where the documentation should point out the error in making common
assumptions about how the function works.

    Writes at most maxSize bytes of data from data to the device.
    Returns the number of bytes that were actually written,
    or -1 if an error occurred.

That would come in first place in a competition for providing
the least documentation possible. Perhaps is should also say...

    The number of bytes written is returned for a reason.
    You should check it and be prepared to take appropriate
    action if it is less than the expected value.
    Also note that writing less than the expected number of bytes
    is not, by itself, considered to be an error.
    ...

Bill

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to