diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-03-03 00:51:40 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-03-03 00:51:40 +0000 |
commit | 34ede34acd5d51ef552d5f8edf9b5d1a4fd0502a (patch) | |
tree | 7847f4c86dbd523cb4038b4ec3b9a8d1a082fe56 /lldb/source/Core/DataBufferMemoryMap.cpp | |
parent | 6b500dc5f9c37ded310ebf626f655a33030b7914 (diff) | |
download | bcm5719-llvm-34ede34acd5d51ef552d5f8edf9b5d1a4fd0502a.tar.gz bcm5719-llvm-34ede34acd5d51ef552d5f8edf9b5d1a4fd0502a.zip |
Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes.
llvm-svn: 262570
Diffstat (limited to 'lldb/source/Core/DataBufferMemoryMap.cpp')
-rw-r--r-- | lldb/source/Core/DataBufferMemoryMap.cpp | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/lldb/source/Core/DataBufferMemoryMap.cpp b/lldb/source/Core/DataBufferMemoryMap.cpp index b3211b35af8..fd8db63c8a7 100644 --- a/lldb/source/Core/DataBufferMemoryMap.cpp +++ b/lldb/source/Core/DataBufferMemoryMap.cpp @@ -7,10 +7,8 @@ // //===----------------------------------------------------------------------===// - -#include <errno.h> +// C Includes #include <fcntl.h> -#include <limits.h> #include <sys/stat.h> #ifdef _WIN32 #include "lldb/Host/windows/windows.h" @@ -18,8 +16,14 @@ #include <sys/mman.h> #endif +// C++ Includes +#include <cerrno> +#include <climits> + +// Other libraries and framework includes #include "llvm/Support/MathExtras.h" +// Project includes #include "lldb/Core/DataBufferMemoryMap.h" #include "lldb/Core/Error.h" #include "lldb/Host/File.h" @@ -34,9 +38,9 @@ using namespace lldb_private; // Default Constructor //---------------------------------------------------------------------- DataBufferMemoryMap::DataBufferMemoryMap() : - m_mmap_addr(NULL), + m_mmap_addr(nullptr), m_mmap_size(0), - m_data(NULL), + m_data(nullptr), m_size(0) { } @@ -51,7 +55,7 @@ DataBufferMemoryMap::~DataBufferMemoryMap() } //---------------------------------------------------------------------- -// Return a pointer to the bytes owned by this object, or NULL if +// Return a pointer to the bytes owned by this object, or nullptr if // the object contains no bytes. //---------------------------------------------------------------------- uint8_t * @@ -61,7 +65,7 @@ DataBufferMemoryMap::GetBytes() } //---------------------------------------------------------------------- -// Return a const pointer to the bytes owned by this object, or NULL +// Return a const pointer to the bytes owned by this object, or nullptr // if the object contains no bytes. //---------------------------------------------------------------------- const uint8_t * @@ -86,7 +90,7 @@ DataBufferMemoryMap::GetByteSize() const void DataBufferMemoryMap::Clear() { - if (m_mmap_addr != NULL) + if (m_mmap_addr != nullptr) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP)); if (log) @@ -97,9 +101,9 @@ DataBufferMemoryMap::Clear() #else ::munmap((void *)m_mmap_addr, m_mmap_size); #endif - m_mmap_addr = NULL; + m_mmap_addr = nullptr; m_mmap_size = 0; - m_data = NULL; + m_data = nullptr; m_size = 0; } } @@ -118,7 +122,7 @@ DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* filespec, size_t length, bool writeable) { - if (filespec != NULL) + if (filespec != nullptr) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP)); if (log) @@ -150,7 +154,6 @@ DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* filespec, return 0; } - #ifdef _WIN32 static size_t win32memmapalignment = 0; void LoadWin32MemMapAlignment () @@ -208,8 +211,8 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd, if (length > 0) { - HANDLE fileMapping = CreateFileMapping(handle, NULL, writeable ? PAGE_READWRITE : PAGE_READONLY, file_size_high, file_size_low, NULL); - if (fileMapping != NULL) + HANDLE fileMapping = CreateFileMapping(handle, nullptr, writeable ? PAGE_READWRITE : PAGE_READONLY, file_size_high, file_size_low, nullptr); + if (fileMapping != nullptr) { if (win32memmapalignment == 0) LoadWin32MemMapAlignment(); lldb::offset_t realoffset = offset; @@ -259,7 +262,7 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd, if (fd_is_file) flags |= MAP_FILE; - m_mmap_addr = (uint8_t *)::mmap(NULL, length, prot, flags, fd, offset); + m_mmap_addr = (uint8_t *)::mmap(nullptr, length, prot, flags, fd, offset); Error error; if (m_mmap_addr == (void*)-1) @@ -271,13 +274,13 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd, size_t page_offset = offset % HostInfo::GetPageSize(); if (page_offset != 0) { - m_mmap_addr = (uint8_t *)::mmap(NULL, length + page_offset, prot, flags, fd, offset - page_offset); + m_mmap_addr = (uint8_t *)::mmap(nullptr, length + page_offset, prot, flags, fd, offset - page_offset); if (m_mmap_addr == (void*)-1) { // Failed to map file - m_mmap_addr = NULL; + m_mmap_addr = nullptr; } - else if (m_mmap_addr != NULL) + else if (m_mmap_addr != nullptr) { // We recovered and were able to memory map // after we aligned things to page boundaries |