Commit dcabef22 by Edward Thomson

futils: produce improved error messages

parent e7be6b76
......@@ -167,12 +167,18 @@ int git_futils_readbuffer_fd(git_str *buf, git_file fd, size_t len)
/* p_read loops internally to read len bytes */
read_size = p_read(fd, buf->ptr, len);
if (read_size != (ssize_t)len) {
if (read_size < 0) {
git_error_set(GIT_ERROR_OS, "failed to read descriptor");
git_str_dispose(buf);
return -1;
}
if ((size_t)read_size != len) {
git_error_set(GIT_ERROR_FILESYSTEM, "could not read (expected %" PRIuZ " bytes, read %" PRIuZ ")", len, (size_t)read_size);
git_str_dispose(buf);
return -1;
}
buf->ptr[read_size] = '\0';
buf->size = read_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment