[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 10:49:02 PDT 2019


teemperor created this revision.
teemperor added a reviewer: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

It's neither used or tested here and in swift-lldb, so let's get rid of it.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67116

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


Index: lldb/source/Host/common/File.cpp
===================================================================
--- lldb/source/Host/common/File.cpp
+++ lldb/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/include/lldb/Host/File.h
===================================================================
--- lldb/include/lldb/Host/File.h
+++ lldb/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.218491.patch
Type: text/x-patch
Size: 3557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190903/46aad642/attachment.bin>


More information about the lldb-commits mailing list