diff options
author | Kostya Kortchinsky <kostyak@google.com> | 2019-08-12 15:35:09 +0000 |
---|---|---|
committer | Kostya Kortchinsky <kostyak@google.com> | 2019-08-12 15:35:09 +0000 |
commit | 0b161aaff0c26d63ed9b815774dacb2421ba212b (patch) | |
tree | 7d0cb87b7fe0481cb26f6cf44ab46e3dd6fd15e9 | |
parent | 0c8ff6968896f82200e6a68b4f5eff63f248982c (diff) | |
download | compiler-rt-0b161aaff0c26d63ed9b815774dacb2421ba212b.tar.gz |
[scudo][standalone] Minor corrections
Summary:
Few corrections with no functional change:
- replacing `%zd` with `%zu` all around: the values are unsigned
- prefer `MAP_ANONYMOUS` to `MAP_ANON` (it's deprecated)
- remove the unused `enum LinkerInitialized`
- mark a parameter as `UNUSED` in Fuchsia's `getRandom`
- correct the casing of a variable and use `nullptr` instead of 0 for
pointers in `list.h`
- reorder some `typedef` to be consistent between `signed` and
`unsigned`
Reviewers: eugenis, vitalybuka, morehouse, hctim
Reviewed By: vitalybuka, morehouse
Subscribers: delcypher, #sanitizers, llvm-commits
Tags: #llvm, #sanitizers
Differential Revision: https://reviews.llvm.org/D65660
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@368585 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/scudo/standalone/fuchsia.cpp | 2 | ||||
-rw-r--r-- | lib/scudo/standalone/internal_defs.h | 4 | ||||
-rw-r--r-- | lib/scudo/standalone/linux.cpp | 2 | ||||
-rw-r--r-- | lib/scudo/standalone/list.h | 12 | ||||
-rw-r--r-- | lib/scudo/standalone/quarantine.h | 6 | ||||
-rw-r--r-- | lib/scudo/standalone/secondary.cpp | 4 |
6 files changed, 14 insertions, 16 deletions
diff --git a/lib/scudo/standalone/fuchsia.cpp b/lib/scudo/standalone/fuchsia.cpp index 273467079..0a9483ae1 100644 --- a/lib/scudo/standalone/fuchsia.cpp +++ b/lib/scudo/standalone/fuchsia.cpp @@ -170,7 +170,7 @@ u64 getMonotonicTime() { return _zx_clock_get_monotonic(); } u32 getNumberOfCPUs() { return _zx_system_get_num_cpus(); } -bool getRandom(void *Buffer, uptr Length, bool Blocking) { +bool getRandom(void *Buffer, uptr Length, UNUSED bool Blocking) { COMPILER_CHECK(MaxRandomLength <= ZX_CPRNG_DRAW_MAX_LEN); if (UNLIKELY(!Buffer || !Length || Length > MaxRandomLength)) return false; diff --git a/lib/scudo/standalone/internal_defs.h b/lib/scudo/standalone/internal_defs.h index 901eac372..64ed238eb 100644 --- a/lib/scudo/standalone/internal_defs.h +++ b/lib/scudo/standalone/internal_defs.h @@ -55,11 +55,11 @@ namespace scudo { typedef unsigned long uptr; -typedef signed long sptr; typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; typedef unsigned long long u64; +typedef signed long sptr; typedef signed char s8; typedef signed short s16; typedef signed int s32; @@ -128,8 +128,6 @@ void NORETURN reportCheckFailed(const char *File, int Line, #define COMPILER_CHECK(Pred) static_assert(Pred, "") -enum LinkerInitialized { LINKER_INITIALIZED = 0 }; - } // namespace scudo #endif // SCUDO_INTERNAL_DEFS_H_ diff --git a/lib/scudo/standalone/linux.cpp b/lib/scudo/standalone/linux.cpp index e9873274a..8266a528f 100644 --- a/lib/scudo/standalone/linux.cpp +++ b/lib/scudo/standalone/linux.cpp @@ -43,7 +43,7 @@ void NORETURN die() { abort(); } void *map(void *Addr, uptr Size, UNUSED const char *Name, uptr Flags, UNUSED MapPlatformData *Data) { - int MmapFlags = MAP_PRIVATE | MAP_ANON; + int MmapFlags = MAP_PRIVATE | MAP_ANONYMOUS; int MmapProt; if (Flags & MAP_NOACCESS) { MmapFlags |= MAP_NORESERVE; diff --git a/lib/scudo/standalone/list.h b/lib/scudo/standalone/list.h index 139e73eff..6a7b9bd74 100644 --- a/lib/scudo/standalone/list.h +++ b/lib/scudo/standalone/list.h @@ -106,17 +106,17 @@ template <class Item> struct IntrusiveList { void checkConsistency() { if (Size == 0) { - CHECK_EQ(First, 0); - CHECK_EQ(Last, 0); + CHECK_EQ(First, nullptr); + CHECK_EQ(Last, nullptr); } else { - uptr count = 0; + uptr Count = 0; for (Item *I = First;; I = I->Next) { - count++; + Count++; if (I == Last) break; } - CHECK_EQ(size(), count); - CHECK_EQ(Last->Next, 0); + CHECK_EQ(size(), Count); + CHECK_EQ(Last->Next, nullptr); } } diff --git a/lib/scudo/standalone/quarantine.h b/lib/scudo/standalone/quarantine.h index bac36e01c..732373aba 100644 --- a/lib/scudo/standalone/quarantine.h +++ b/lib/scudo/standalone/quarantine.h @@ -152,8 +152,8 @@ public: (TotalQuarantinedBytes == 0) ? 0 : TotalOverheadBytes * 100 / TotalQuarantinedBytes; - Printf("Global quarantine stats: batches: %zd; bytes: %zd (user: %zd); " - "chunks: %zd (capacity: %zd); %zd%% chunks used; %zd%% memory " + Printf("Global quarantine stats: batches: %zu; bytes: %zu (user: %zu); " + "chunks: %zu (capacity: %zu); %zu%% chunks used; %zu%% memory " "overhead\n", BatchCount, TotalBytes, TotalQuarantinedBytes, TotalQuarantineChunks, QuarantineChunksCapacity, ChunksUsagePercent, MemoryOverheadPercent); @@ -220,7 +220,7 @@ public: void printStats() const { // It assumes that the world is stopped, just as the allocator's printStats. - Printf("Quarantine limits: global: %zdM; thread local: %zdK\n", + Printf("Quarantine limits: global: %zuM; thread local: %zuK\n", getMaxSize() >> 20, getCacheSize() >> 10); Cache.printStats(); } diff --git a/lib/scudo/standalone/secondary.cpp b/lib/scudo/standalone/secondary.cpp index 4f35b020c..d725034ee 100644 --- a/lib/scudo/standalone/secondary.cpp +++ b/lib/scudo/standalone/secondary.cpp @@ -124,8 +124,8 @@ void MapAllocator::deallocate(void *Ptr) { } void MapAllocator::printStats() const { - Printf("Stats: MapAllocator: allocated %zd times (%zdK), freed %zd times " - "(%zdK), remains %zd (%zdK) max %zdM\n", + Printf("Stats: MapAllocator: allocated %zu times (%zuK), freed %zu times " + "(%zuK), remains %zu (%zuK) max %zuM\n", NumberOfAllocs, AllocatedBytes >> 10, NumberOfFrees, FreedBytes >> 10, NumberOfAllocs - NumberOfFrees, (AllocatedBytes - FreedBytes) >> 10, LargestSize >> 20); |