The write system call prototype is:
ssize_t write(int fd, const void *buf, size_t count);
The count parameter is unsigned, and the return value is signed.
The help page says:
On success, the number of bytes written is returned (zero indicates nothing was written).
On error, -1 is returned, and errno is set appropriately.
However, it doesn't say what is the limit to the count parameter.
It still doesn't say the behavior when count is greater than SSIZE_MAX.
Considering write is a system call that can be used to generic devices/files/whatever, if the device supports write operations bigger than SSIZE_MAX, the returning type can't handle the real number of bytes writen.
Doesn't make sense to me to be able to pass an unsigned number of bytes and get back an signed number of bytes as a result. Why not just pass an signed number?
It feels like the prototype of the write function in sort of error prone, or at least it leaves a possible hole in the path.
Does anyone knows the details about it or where can I find this information?