Don't check the validity of newly contructed data buffers
authorPavel Labath <pavel@labath.sk>
Mon, 1 Jul 2019 13:18:19 +0000 (13:18 +0000)
committerPavel Labath <pavel@labath.sk>
Mon, 1 Jul 2019 13:18:19 +0000 (13:18 +0000)
A bunch of places were checking that DataBufferHeap::GetBytes returns a
non-null pointer right after constructing it. The only time when
GetBytes returns a null pointer is if it is empty (and I'm not sure that
even this is a good idea), but that is clearly not the case here, as the
buffer was constructed with a non-zero size just a couple of lines back.

llvm-svn: 364754

lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp
lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp

index 6204dbe..d720619 100644 (file)
@@ -285,13 +285,6 @@ Status NativeRegisterContextLinux_arm::ReadAllRegisterValues(
     return error;
 
   uint8_t *dst = data_sp->GetBytes();
-  if (dst == nullptr) {
-    error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
-                                   " returned a null pointer",
-                                   (uint64_t)REG_CONTEXT_SIZE);
-    return error;
-  }
-
   ::memcpy(dst, &m_gpr_arm, GetGPRSize());
   dst += GetGPRSize();
   ::memcpy(dst, &m_fpr, sizeof(m_fpr));
index 3a232e0..9bb9e6b 100644 (file)
@@ -286,13 +286,6 @@ Status NativeRegisterContextLinux_arm64::ReadAllRegisterValues(
     return error;
 
   uint8_t *dst = data_sp->GetBytes();
-  if (dst == nullptr) {
-    error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
-                                   " returned a null pointer",
-                                   REG_CONTEXT_SIZE);
-    return error;
-  }
-
   ::memcpy(dst, &m_gpr_arm64, GetGPRSize());
   dst += GetGPRSize();
   ::memcpy(dst, &m_fpr, sizeof(m_fpr));
index 4f91596..6e4fe59 100644 (file)
@@ -394,13 +394,6 @@ Status NativeRegisterContextLinux_mips64::ReadAllRegisterValues(
   }
 
   uint8_t *dst = data_sp->GetBytes();
-  if (dst == nullptr) {
-    error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
-                                   " returned a null pointer",
-                                   REG_CONTEXT_SIZE);
-    return error;
-  }
-
   ::memcpy(dst, &m_gpr, GetRegisterInfoInterface().GetGPRSize());
   dst += GetRegisterInfoInterface().GetGPRSize();
 
index 8e99a09..11cf1a2 100644 (file)
@@ -371,13 +371,6 @@ Status NativeRegisterContextLinux_ppc64le::ReadAllRegisterValues(
     return error;
 
   uint8_t *dst = data_sp->GetBytes();
-  if (dst == nullptr) {
-    error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
-                                   " returned a null pointer",
-                                   REG_CONTEXT_SIZE);
-    return error;
-  }
-
   ::memcpy(dst, &m_gpr_ppc64le, GetGPRSize());
   dst += GetGPRSize();
   ::memcpy(dst, &m_fpr_ppc64le, GetFPRSize());
index 5a26898..b44bb93 100644 (file)
@@ -337,13 +337,6 @@ Status NativeRegisterContextLinux_s390x::ReadAllRegisterValues(
 
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
   uint8_t *dst = data_sp->GetBytes();
-  if (dst == nullptr) {
-    error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
-                                   " returned a null pointer",
-                                   REG_CONTEXT_SIZE);
-    return error;
-  }
-
   error = DoReadGPR(dst, sizeof(s390_regs));
   dst += sizeof(s390_regs);
   if (error.Fail())
index 1a4d453..c91e9bf 100644 (file)
@@ -577,13 +577,6 @@ Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues(
     return error;
 
   uint8_t *dst = data_sp->GetBytes();
-  if (dst == nullptr) {
-    error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
-                                   " returned a null pointer",
-                                   REG_CONTEXT_SIZE);
-    return error;
-  }
-
   ::memcpy(dst, &m_gpr_x86_64, GetRegisterInfoInterface().GetGPRSize());
   dst += GetRegisterInfoInterface().GetGPRSize();