Skip to content

Commit 0b161aa

Browse files
author
Kostya Kortchinsky
committed
[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
1 parent 0c8ff69 commit 0b161aa

File tree

6 files changed

+14
-16
lines changed

6 files changed

+14
-16
lines changed

lib/scudo/standalone/fuchsia.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ u64 getMonotonicTime() { return _zx_clock_get_monotonic(); }
170170

171171
u32 getNumberOfCPUs() { return _zx_system_get_num_cpus(); }
172172

173-
bool getRandom(void *Buffer, uptr Length, bool Blocking) {
173+
bool getRandom(void *Buffer, uptr Length, UNUSED bool Blocking) {
174174
COMPILER_CHECK(MaxRandomLength <= ZX_CPRNG_DRAW_MAX_LEN);
175175
if (UNLIKELY(!Buffer || !Length || Length > MaxRandomLength))
176176
return false;

lib/scudo/standalone/internal_defs.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
namespace scudo {
5656

5757
typedef unsigned long uptr;
58-
typedef signed long sptr;
5958
typedef unsigned char u8;
6059
typedef unsigned short u16;
6160
typedef unsigned int u32;
6261
typedef unsigned long long u64;
62+
typedef signed long sptr;
6363
typedef signed char s8;
6464
typedef signed short s16;
6565
typedef signed int s32;
@@ -128,8 +128,6 @@ void NORETURN reportCheckFailed(const char *File, int Line,
128128

129129
#define COMPILER_CHECK(Pred) static_assert(Pred, "")
130130

131-
enum LinkerInitialized { LINKER_INITIALIZED = 0 };
132-
133131
} // namespace scudo
134132

135133
#endif // SCUDO_INTERNAL_DEFS_H_

lib/scudo/standalone/linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void NORETURN die() { abort(); }
4343

4444
void *map(void *Addr, uptr Size, UNUSED const char *Name, uptr Flags,
4545
UNUSED MapPlatformData *Data) {
46-
int MmapFlags = MAP_PRIVATE | MAP_ANON;
46+
int MmapFlags = MAP_PRIVATE | MAP_ANONYMOUS;
4747
int MmapProt;
4848
if (Flags & MAP_NOACCESS) {
4949
MmapFlags |= MAP_NORESERVE;

lib/scudo/standalone/list.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,17 @@ template <class Item> struct IntrusiveList {
106106

107107
void checkConsistency() {
108108
if (Size == 0) {
109-
CHECK_EQ(First, 0);
110-
CHECK_EQ(Last, 0);
109+
CHECK_EQ(First, nullptr);
110+
CHECK_EQ(Last, nullptr);
111111
} else {
112-
uptr count = 0;
112+
uptr Count = 0;
113113
for (Item *I = First;; I = I->Next) {
114-
count++;
114+
Count++;
115115
if (I == Last)
116116
break;
117117
}
118-
CHECK_EQ(size(), count);
119-
CHECK_EQ(Last->Next, 0);
118+
CHECK_EQ(size(), Count);
119+
CHECK_EQ(Last->Next, nullptr);
120120
}
121121
}
122122

lib/scudo/standalone/quarantine.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ template <typename Callback> class QuarantineCache {
152152
(TotalQuarantinedBytes == 0)
153153
? 0
154154
: TotalOverheadBytes * 100 / TotalQuarantinedBytes;
155-
Printf("Global quarantine stats: batches: %zd; bytes: %zd (user: %zd); "
156-
"chunks: %zd (capacity: %zd); %zd%% chunks used; %zd%% memory "
155+
Printf("Global quarantine stats: batches: %zu; bytes: %zu (user: %zu); "
156+
"chunks: %zu (capacity: %zu); %zu%% chunks used; %zu%% memory "
157157
"overhead\n",
158158
BatchCount, TotalBytes, TotalQuarantinedBytes, TotalQuarantineChunks,
159159
QuarantineChunksCapacity, ChunksUsagePercent, MemoryOverheadPercent);
@@ -220,7 +220,7 @@ template <typename Callback, typename Node> class GlobalQuarantine {
220220

221221
void printStats() const {
222222
// It assumes that the world is stopped, just as the allocator's printStats.
223-
Printf("Quarantine limits: global: %zdM; thread local: %zdK\n",
223+
Printf("Quarantine limits: global: %zuM; thread local: %zuK\n",
224224
getMaxSize() >> 20, getCacheSize() >> 10);
225225
Cache.printStats();
226226
}

lib/scudo/standalone/secondary.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ void MapAllocator::deallocate(void *Ptr) {
124124
}
125125

126126
void MapAllocator::printStats() const {
127-
Printf("Stats: MapAllocator: allocated %zd times (%zdK), freed %zd times "
128-
"(%zdK), remains %zd (%zdK) max %zdM\n",
127+
Printf("Stats: MapAllocator: allocated %zu times (%zuK), freed %zu times "
128+
"(%zuK), remains %zu (%zuK) max %zuM\n",
129129
NumberOfAllocs, AllocatedBytes >> 10, NumberOfFrees, FreedBytes >> 10,
130130
NumberOfAllocs - NumberOfFrees, (AllocatedBytes - FreedBytes) >> 10,
131131
LargestSize >> 20);

0 commit comments

Comments
 (0)