Skip to content

Commit 567a8f4

Browse files
labathadrian-prantl
authored andcommitted
Don't check the validity of newly contructed data buffers
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 (cherry picked from commit c12dfcf)
1 parent 855d1aa commit 567a8f4

6 files changed

+0
-42
lines changed

lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,6 @@ Status NativeRegisterContextLinux_arm::ReadAllRegisterValues(
285285
return error;
286286

287287
uint8_t *dst = data_sp->GetBytes();
288-
if (dst == nullptr) {
289-
error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
290-
" returned a null pointer",
291-
(uint64_t)REG_CONTEXT_SIZE);
292-
return error;
293-
}
294-
295288
::memcpy(dst, &m_gpr_arm, GetGPRSize());
296289
dst += GetGPRSize();
297290
::memcpy(dst, &m_fpr, sizeof(m_fpr));

lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,6 @@ Status NativeRegisterContextLinux_arm64::ReadAllRegisterValues(
286286
return error;
287287

288288
uint8_t *dst = data_sp->GetBytes();
289-
if (dst == nullptr) {
290-
error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
291-
" returned a null pointer",
292-
REG_CONTEXT_SIZE);
293-
return error;
294-
}
295-
296289
::memcpy(dst, &m_gpr_arm64, GetGPRSize());
297290
dst += GetGPRSize();
298291
::memcpy(dst, &m_fpr, sizeof(m_fpr));

lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,6 @@ Status NativeRegisterContextLinux_mips64::ReadAllRegisterValues(
394394
}
395395

396396
uint8_t *dst = data_sp->GetBytes();
397-
if (dst == nullptr) {
398-
error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
399-
" returned a null pointer",
400-
REG_CONTEXT_SIZE);
401-
return error;
402-
}
403-
404397
::memcpy(dst, &m_gpr, GetRegisterInfoInterface().GetGPRSize());
405398
dst += GetRegisterInfoInterface().GetGPRSize();
406399

lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,6 @@ Status NativeRegisterContextLinux_ppc64le::ReadAllRegisterValues(
371371
return error;
372372

373373
uint8_t *dst = data_sp->GetBytes();
374-
if (dst == nullptr) {
375-
error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
376-
" returned a null pointer",
377-
REG_CONTEXT_SIZE);
378-
return error;
379-
}
380-
381374
::memcpy(dst, &m_gpr_ppc64le, GetGPRSize());
382375
dst += GetGPRSize();
383376
::memcpy(dst, &m_fpr_ppc64le, GetFPRSize());

lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,6 @@ Status NativeRegisterContextLinux_s390x::ReadAllRegisterValues(
337337

338338
data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
339339
uint8_t *dst = data_sp->GetBytes();
340-
if (dst == nullptr) {
341-
error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
342-
" returned a null pointer",
343-
REG_CONTEXT_SIZE);
344-
return error;
345-
}
346-
347340
error = DoReadGPR(dst, sizeof(s390_regs));
348341
dst += sizeof(s390_regs);
349342
if (error.Fail())

lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,13 +577,6 @@ Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues(
577577
return error;
578578

579579
uint8_t *dst = data_sp->GetBytes();
580-
if (dst == nullptr) {
581-
error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
582-
" returned a null pointer",
583-
REG_CONTEXT_SIZE);
584-
return error;
585-
}
586-
587580
::memcpy(dst, &m_gpr_x86_64, GetRegisterInfoInterface().GetGPRSize());
588581
dst += GetRegisterInfoInterface().GetGPRSize();
589582

0 commit comments

Comments
 (0)