[Lldb-commits] [lldb] r369492 - [NFC] Remove unused function GetHexWithFixedSize

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 20 21:55:53 PDT 2019


Author: jdevlieghere
Date: Tue Aug 20 21:55:53 2019
New Revision: 369492

URL: http://llvm.org/viewvc/llvm-project?rev=369492&view=rev
Log:
[NFC] Remove unused function GetHexWithFixedSize

The implementation of this function was obviously incorrect, as the
result variable was never used. This led me to check if it was actually
used anywhere, which came back negative.

Modified:
    lldb/trunk/include/lldb/Utility/StringExtractor.h
    lldb/trunk/source/Utility/StringExtractor.cpp
    lldb/trunk/tools/debugserver/source/StdStringExtractor.cpp
    lldb/trunk/tools/debugserver/source/StdStringExtractor.h

Modified: lldb/trunk/include/lldb/Utility/StringExtractor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/StringExtractor.h?rev=369492&r1=369491&r2=369492&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/StringExtractor.h (original)
+++ lldb/trunk/include/lldb/Utility/StringExtractor.h Tue Aug 20 21:55:53 2019
@@ -91,9 +91,6 @@ public:
 
   size_t GetHexBytesAvail(llvm::MutableArrayRef<uint8_t> dest);
 
-  uint64_t GetHexWithFixedSize(uint32_t byte_size, bool little_endian,
-                               uint64_t fail_value);
-
   size_t GetHexByteString(std::string &str);
 
   size_t GetHexByteStringFixedLength(std::string &str, uint32_t nibble_length);
@@ -113,12 +110,14 @@ protected:
     m_index = UINT64_MAX;
     return false;
   }
-  // For StringExtractor only
-  std::string m_packet; // The string in which to extract data.
-  uint64_t m_index;     // When extracting data from a packet, this index
-                        // will march along as things get extracted. If set to
-                        // UINT64_MAX the end of the packet data was reached
-                        // when decoding information
+
+  /// The string in which to extract data.
+  std::string m_packet;
+
+  /// When extracting data from a packet, this index will march along as things
+  /// get extracted. If set to UINT64_MAX the end of the packet data was
+  /// reached when decoding information.
+  uint64_t m_index;
 };
 
 #endif // utility_StringExtractor_h_

Modified: lldb/trunk/source/Utility/StringExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringExtractor.cpp?rev=369492&r1=369491&r2=369492&view=diff
==============================================================================
--- lldb/trunk/source/Utility/StringExtractor.cpp (original)
+++ lldb/trunk/source/Utility/StringExtractor.cpp Tue Aug 20 21:55:53 2019
@@ -296,34 +296,6 @@ size_t StringExtractor::GetHexBytesAvail
   return bytes_extracted;
 }
 
-// Consume ASCII hex nibble character pairs until we have decoded byte_size
-// bytes of data.
-
-uint64_t StringExtractor::GetHexWithFixedSize(uint32_t byte_size,
-                                              bool little_endian,
-                                              uint64_t fail_value) {
-  if (byte_size <= 8 && GetBytesLeft() >= byte_size * 2) {
-    uint64_t result = 0;
-    uint32_t i;
-    if (little_endian) {
-      // Little Endian
-      uint32_t shift_amount;
-      for (i = 0, shift_amount = 0; i < byte_size && IsGood();
-           ++i, shift_amount += 8) {
-        result |= (static_cast<uint64_t>(GetHexU8()) << shift_amount);
-      }
-    } else {
-      // Big Endian
-      for (i = 0; i < byte_size && IsGood(); ++i) {
-        result <<= 8;
-        result |= GetHexU8();
-      }
-    }
-  }
-  m_index = UINT64_MAX;
-  return fail_value;
-}
-
 size_t StringExtractor::GetHexByteString(std::string &str) {
   str.clear();
   str.reserve(GetBytesLeft() / 2);

Modified: lldb/trunk/tools/debugserver/source/StdStringExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/StdStringExtractor.cpp?rev=369492&r1=369491&r2=369492&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/StdStringExtractor.cpp (original)
+++ lldb/trunk/tools/debugserver/source/StdStringExtractor.cpp Tue Aug 20 21:55:53 2019
@@ -281,34 +281,6 @@ size_t StdStringExtractor::GetHexBytesAv
   return bytes_extracted;
 }
 
-// Consume ASCII hex nibble character pairs until we have decoded byte_size
-// bytes of data.
-
-uint64_t StdStringExtractor::GetHexWithFixedSize(uint32_t byte_size,
-                                                 bool little_endian,
-                                                 uint64_t fail_value) {
-  if (byte_size <= 8 && GetBytesLeft() >= byte_size * 2) {
-    uint64_t result = 0;
-    uint32_t i;
-    if (little_endian) {
-      // Little Endian
-      uint32_t shift_amount;
-      for (i = 0, shift_amount = 0; i < byte_size && IsGood();
-           ++i, shift_amount += 8) {
-        result |= ((uint64_t)GetHexU8() << shift_amount);
-      }
-    } else {
-      // Big Endian
-      for (i = 0; i < byte_size && IsGood(); ++i) {
-        result <<= 8;
-        result |= GetHexU8();
-      }
-    }
-  }
-  m_index = UINT64_MAX;
-  return fail_value;
-}
-
 size_t StdStringExtractor::GetHexByteString(std::string &str) {
   str.clear();
   str.reserve(GetBytesLeft() / 2);

Modified: lldb/trunk/tools/debugserver/source/StdStringExtractor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/StdStringExtractor.h?rev=369492&r1=369491&r2=369492&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/StdStringExtractor.h (original)
+++ lldb/trunk/tools/debugserver/source/StdStringExtractor.h Tue Aug 20 21:55:53 2019
@@ -83,9 +83,6 @@ public:
 
   size_t GetHexBytesAvail(void *dst, size_t dst_len);
 
-  uint64_t GetHexWithFixedSize(uint32_t byte_size, bool little_endian,
-                               uint64_t fail_value);
-
   size_t GetHexByteString(std::string &str);
 
   size_t GetHexByteStringFixedLength(std::string &str, uint32_t nibble_length);




More information about the lldb-commits mailing list