[Lldb-commits] [PATCH] D67116: [lldb][NFC] Remove unused overload of File::Read

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 3 11:11:24 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL370802: [lldb][NFC] Remove unused overload of File::Read (authored by teemperor, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67116?vs=218491&id=218496#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67116/new/

https://reviews.llvm.org/D67116

Files:
  lldb/trunk/include/lldb/Host/File.h
  lldb/trunk/source/Host/common/File.cpp


Index: lldb/trunk/source/Host/common/File.cpp
===================================================================
--- lldb/trunk/source/Host/common/File.cpp
+++ lldb/trunk/source/Host/common/File.cpp
@@ -513,50 +513,6 @@
   return error;
 }
 
-Status File::Read(size_t &num_bytes, off_t &offset, bool null_terminate,
-                  DataBufferSP &data_buffer_sp) {
-  Status error;
-
-  if (num_bytes > 0) {
-    int fd = GetDescriptor();
-    if (fd != kInvalidDescriptor) {
-      struct stat file_stats;
-      if (::fstat(fd, &file_stats) == 0) {
-        if (file_stats.st_size > offset) {
-          const size_t bytes_left = file_stats.st_size - offset;
-          if (num_bytes > bytes_left)
-            num_bytes = bytes_left;
-
-          size_t num_bytes_plus_nul_char = num_bytes + (null_terminate ? 1 : 0);
-          std::unique_ptr<DataBufferHeap> data_heap_up;
-          data_heap_up.reset(new DataBufferHeap());
-          data_heap_up->SetByteSize(num_bytes_plus_nul_char);
-
-          if (data_heap_up) {
-            error = Read(data_heap_up->GetBytes(), num_bytes, offset);
-            if (error.Success()) {
-              // Make sure we read exactly what we asked for and if we got
-              // less, adjust the array
-              if (num_bytes_plus_nul_char < data_heap_up->GetByteSize())
-                data_heap_up->SetByteSize(num_bytes_plus_nul_char);
-              data_buffer_sp.reset(data_heap_up.release());
-              return error;
-            }
-          }
-        } else
-          error.SetErrorString("file is empty");
-      } else
-        error.SetErrorToErrno();
-    } else
-      error.SetErrorString("invalid file handle");
-  } else
-    error.SetErrorString("invalid file handle");
-
-  num_bytes = 0;
-  data_buffer_sp.reset();
-  return error;
-}
-
 Status File::Write(const void *buf, size_t &num_bytes, off_t &offset) {
   Status error;
 
Index: lldb/trunk/include/lldb/Host/File.h
===================================================================
--- lldb/trunk/include/lldb/Host/File.h
+++ lldb/trunk/include/lldb/Host/File.h
@@ -252,36 +252,6 @@
   ///     failure.
   Status Read(void *dst, size_t &num_bytes, off_t &offset);
 
-  /// Read bytes from a file from the specified file offset.
-  ///
-  /// NOTE: This function is thread safe in that clients manager their
-  /// own file position markers and reads on other threads won't mess up the
-  /// current read.
-  ///
-  /// \param[in,out] num_bytes
-  ///     The number of bytes to read form the current file position
-  ///     which gets modified with the number of bytes that were read.
-  ///
-  /// \param[in,out] offset
-  ///     The offset within the file from which to read \a num_bytes
-  ///     bytes. This offset gets incremented by the number of bytes
-  ///     that were read.
-  ///
-  /// \param[in] null_terminate
-  ///     Ensure that the data that is read is terminated with a NULL
-  ///     character so that the data can be used as a C string.
-  ///
-  /// \param[out] data_buffer_sp
-  ///     A data buffer to create and fill in that will contain any
-  ///     data that is read from the file. This buffer will be reset
-  ///     if an error occurs.
-  ///
-  /// \return
-  ///     An error object that indicates success or the reason for
-  ///     failure.
-  Status Read(size_t &num_bytes, off_t &offset, bool null_terminate,
-              lldb::DataBufferSP &data_buffer_sp);
-
   /// Write bytes to a file at the specified file offset.
   ///
   /// NOTE: This function is thread safe in that clients manager their


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67116.218496.patch
Type: text/x-patch
Size: 3593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190903/d2434a8a/attachment.bin>


More information about the lldb-commits mailing list