Instead of having three possible returns (a pointer to the NUL byte, the
end of the array, or NULL), reduce it to two possible ones: one for
success, and one for error.
Use errno, which is a common way to signal the specific error, and thus
treat truncation as any other error. This simplifies error handling
after these calls. Also, if one misuses a pointer after truncation, the
results are better if the pointer is NULL: the program will easily
abort. If we returned 'end', the program could more easily produce a
buffer overrun.
Suggested-by: Douglas McIlroy <douglas.mcilroy@dartmouth.edu> Signed-off-by: Alejandro Colomar <alx@kernel.org>