[Lldb-commits] [PATCH] D28305: [Host] Handle short reads and writes, take 3

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 4 11:10:38 PST 2017


clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

This change removes support for using a FILE* instead of a file descriptor. This needs to be fixed. The old Read function used to do this:

  ssize_t bytes_read = -1;
  if (DescriptorIsValid()) {
    do {
      bytes_read = ::read(m_descriptor, buf, num_bytes);
    } while (bytes_read < 0 && errno == EINTR);
  
    if (bytes_read == -1) {
      error.SetErrorToErrno();
      num_bytes = 0;
    } else
      num_bytes = bytes_read;
  } else if (StreamIsValid()) {
    bytes_read = ::fread(buf, 1, num_bytes, m_stream);
  
    if (bytes_read == 0) {
      if (::feof(m_stream))
        error.SetErrorString("feof");
      else if (::ferror(m_stream))
        error.SetErrorString("ferror");
      num_bytes = 0;
    } else
      num_bytes = bytes_read;
  } else {
    num_bytes = 0;
    error.SetErrorString("invalid file handle");
  }
  return error;

Note the "else if (StreamIsValid()) {" section.


https://reviews.llvm.org/D28305





More information about the lldb-commits mailing list