[compiler-rt] r368585 - [scudo][standalone] Minor corrections
Kostya Kortchinsky via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 12 08:35:09 PDT 2019
Author: cryptoad
Date: Mon Aug 12 08:35:09 2019
New Revision: 368585
URL: http://llvm.org/viewvc/llvm-project?rev=368585&view=rev
Log:
[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
Modified:
compiler-rt/trunk/lib/scudo/standalone/fuchsia.cpp
compiler-rt/trunk/lib/scudo/standalone/internal_defs.h
compiler-rt/trunk/lib/scudo/standalone/linux.cpp
compiler-rt/trunk/lib/scudo/standalone/list.h
compiler-rt/trunk/lib/scudo/standalone/quarantine.h
compiler-rt/trunk/lib/scudo/standalone/secondary.cpp
Modified: compiler-rt/trunk/lib/scudo/standalone/fuchsia.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/fuchsia.cpp?rev=368585&r1=368584&r2=368585&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/fuchsia.cpp (original)
+++ compiler-rt/trunk/lib/scudo/standalone/fuchsia.cpp Mon Aug 12 08:35:09 2019
@@ -170,7 +170,7 @@ u64 getMonotonicTime() { return _zx_cloc
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;
Modified: compiler-rt/trunk/lib/scudo/standalone/internal_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/internal_defs.h?rev=368585&r1=368584&r2=368585&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/internal_defs.h (original)
+++ compiler-rt/trunk/lib/scudo/standalone/internal_defs.h Mon Aug 12 08:35:09 2019
@@ -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 ch
#define COMPILER_CHECK(Pred) static_assert(Pred, "")
-enum LinkerInitialized { LINKER_INITIALIZED = 0 };
-
} // namespace scudo
#endif // SCUDO_INTERNAL_DEFS_H_
Modified: compiler-rt/trunk/lib/scudo/standalone/linux.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/linux.cpp?rev=368585&r1=368584&r2=368585&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/linux.cpp (original)
+++ compiler-rt/trunk/lib/scudo/standalone/linux.cpp Mon Aug 12 08:35:09 2019
@@ -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;
Modified: compiler-rt/trunk/lib/scudo/standalone/list.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/list.h?rev=368585&r1=368584&r2=368585&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/list.h (original)
+++ compiler-rt/trunk/lib/scudo/standalone/list.h Mon Aug 12 08:35:09 2019
@@ -106,17 +106,17 @@ template <class Item> struct IntrusiveLi
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);
}
}
Modified: compiler-rt/trunk/lib/scudo/standalone/quarantine.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/quarantine.h?rev=368585&r1=368584&r2=368585&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/quarantine.h (original)
+++ compiler-rt/trunk/lib/scudo/standalone/quarantine.h Mon Aug 12 08:35:09 2019
@@ -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();
}
Modified: compiler-rt/trunk/lib/scudo/standalone/secondary.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/secondary.cpp?rev=368585&r1=368584&r2=368585&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/secondary.cpp (original)
+++ compiler-rt/trunk/lib/scudo/standalone/secondary.cpp Mon Aug 12 08:35:09 2019
@@ -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);
More information about the llvm-commits
mailing list