Skip to content

Commit dd0e770

Browse files
committed
code cleanup: remove all instances of assert(this);
1 parent af143f3 commit dd0e770

File tree

247 files changed

+40
-1831
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+40
-1831
lines changed

doc/status_monitoring.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ for class `TMsg`, which represents a single message:
7171
7272
```C++
7373
TMsg::~TMsg() {
74-
assert(this);
7574
MsgDestroy.Increment();
7675
7776
if (State != TState::Processed) {

src/base/backoff_rate_limiter.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ TBackoffRateLimiter::TBackoffRateLimiter(
5757
}
5858

5959
size_t TBackoffRateLimiter::ComputeDelay() {
60-
assert(this);
6160
struct timespec now;
6261
GetCurrentTime(now);
6362

@@ -79,8 +78,6 @@ size_t TBackoffRateLimiter::ComputeDelay() {
7978

8079
bool
8180
TBackoffRateLimiter::InBackoffWindow(const struct timespec &now) noexcept {
82-
assert(this);
83-
8481
if (FirstTime) {
8582
FirstTime = false;
8683
return false;

src/base/backoff_rate_limiter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ namespace Base {
6060
the internal state of the rate limiter so it will correctly compute the
6161
next delay value. */
6262
void OnAction() noexcept {
63-
assert(this);
6463
GetCurrentTime(LastEventTime);
6564
}
6665

src/base/blocking_asset.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,22 @@ namespace Base {
4545
The target must not currently be locked by any thread.
4646
Destroying a locked target has undefined results. */
4747
~TBlockingAsset() {
48-
assert(this);
4948
Wr::pthread_rwlock_destroy(&RwLock);
5049
}
5150

5251
void AcquireExclusive() const noexcept {
53-
assert(this);
5452
Wr::pthread_rwlock_wrlock(&RwLock);
5553
}
5654

5755
void AcquireShared() const noexcept {
58-
assert(this);
5956
Wr::pthread_rwlock_rdlock(&RwLock);
6057
}
6158

6259
void ReleaseExclusive() const noexcept {
63-
assert(this);
6460
Wr::pthread_rwlock_unlock(&RwLock);
6561
}
6662

6763
void ReleaseShared() const noexcept {
68-
assert(this);
6964
Wr::pthread_rwlock_unlock(&RwLock);
7065
}
7166

src/base/buf.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ namespace Base {
7474

7575
/* Move assignment operator leaves 'that' empty. */
7676
TBuf &operator=(TBuf &&that) noexcept {
77-
assert(this);
78-
7977
if (&that != this) {
8078
Storage = std::move(that.Storage);
8179
ItemOffset = that.ItemOffset;
@@ -90,7 +88,6 @@ namespace Base {
9088
/* Move-assign 'items' into buffer, making 'items' its new contents. May
9189
be used in combination with TakeStorage() to refill buffer. */
9290
TBuf &operator=(TStorage &&items) {
93-
assert(this);
9491
Storage = std::move(items);
9592
ItemOffset = 0;
9693
ItemCount = Storage.size();
@@ -99,9 +96,6 @@ namespace Base {
9996

10097
/* Swap contents with contents of 'that'. */
10198
void Swap(TBuf &that) noexcept {
102-
assert(this);
103-
assert(&that);
104-
10599
if (&that != this) {
106100
Storage.swap(that.Storage);
107101
std::swap(ItemOffset, that.ItemOffset);
@@ -111,7 +105,6 @@ namespace Base {
111105

112106
/* Mark all data as consumed, leaving nothing but empty space. */
113107
void Clear() noexcept {
114-
assert(this);
115108
MarkDataConsumed(ItemCount);
116109
}
117110

@@ -122,7 +115,6 @@ namespace Base {
122115
by routines that take as input a vector to fill with data. It allows
123116
underlying memory allocated for storage to be reused. */
124117
TStorage TakeStorage() noexcept {
125-
assert(this);
126118
ItemOffset = 0;
127119
ItemCount = 0;
128120
return std::move(Storage);
@@ -131,7 +123,6 @@ namespace Base {
131123
/* Return pointer to start location where additional items are expected to
132124
be deposited. Do not call unless SpaceSize() returns a value > 0. */
133125
T *Space() noexcept {
134-
assert(this);
135126
assert(ItemOffset < Storage.size());
136127
assert(ItemCount < (Storage.size() - ItemOffset));
137128
assert(SpaceSize() > 0);
@@ -140,7 +131,6 @@ namespace Base {
140131

141132
/* Return number of items the region returned by Space() can hold. */
142133
size_t SpaceSize() const noexcept {
143-
assert(this);
144134
assert(Storage.empty() || (ItemOffset < Storage.size()));
145135
assert(ItemCount <= (Storage.size() - ItemOffset));
146136
return Storage.size() - ItemOffset - ItemCount;
@@ -149,7 +139,6 @@ namespace Base {
149139
/* Return true if buffer currently has no space where additional items can
150140
be deposited, or false otherwise. */
151141
bool SpaceIsEmpty() const noexcept {
152-
assert(this);
153142
assert(Storage.empty() || (ItemOffset < Storage.size()));
154143
assert(ItemCount <= (Storage.size() - ItemOffset));
155144
return (SpaceSize() == 0);
@@ -158,7 +147,6 @@ namespace Base {
158147
/* Return pointer to start location of received items that are ready to be
159148
consumed. Do not call unless DataSize() returns a value > 0. */
160149
T *Data() noexcept {
161-
assert(this);
162150
assert(ItemOffset < Storage.size());
163151
assert(ItemCount <= (Storage.size() - ItemOffset));
164152
assert(DataSize() > 0);
@@ -168,7 +156,6 @@ namespace Base {
168156
/* Return const pointer to start location of received items that are ready
169157
to be consumed. Do not call unless DataSize() returns a value > 0. */
170158
const T *Data() const noexcept {
171-
assert(this);
172159
assert(ItemOffset < Storage.size());
173160
assert(ItemCount <= (Storage.size() - ItemOffset));
174161
assert(DataSize() > 0);
@@ -177,7 +164,6 @@ namespace Base {
177164

178165
/* Return number of items the region returned by Data() holds. */
179166
size_t DataSize() const noexcept {
180-
assert(this);
181167
assert(Storage.empty() || (ItemOffset < Storage.size()));
182168
assert(ItemCount <= (Storage.size() - ItemOffset));
183169
return ItemCount;
@@ -186,7 +172,6 @@ namespace Base {
186172
/* Return true if buffer currently has no received items that are ready to
187173
be consumed, or false otherwise. */
188174
bool DataIsEmpty() const noexcept {
189-
assert(this);
190175
assert(Storage.empty() || (ItemOffset < Storage.size()));
191176
assert(ItemCount <= (Storage.size() - ItemOffset));
192177
return (DataSize() == 0);
@@ -196,7 +181,6 @@ namespace Base {
196181
without allocating memory. This method is a no-op if the buffer is
197182
empty or its items are already at the front. */
198183
void MoveDataToFront() noexcept {
199-
assert(this);
200184
assert(Storage.empty() || (ItemOffset < Storage.size()));
201185
assert(ItemCount <= (Storage.size() - ItemOffset));
202186

@@ -215,7 +199,6 @@ namespace Base {
215199
'min_to_add' items. Note that moving the items to the front may make
216200
more than 'min_to_add' extra space available. */
217201
void AddSpace(size_t min_to_add) {
218-
assert(this);
219202
assert(Storage.empty() || (ItemOffset < Storage.size()));
220203
assert(ItemCount <= (Storage.size() - ItemOffset));
221204

@@ -228,7 +211,6 @@ namespace Base {
228211
necessary, move items to front of buffer and possibly allocate
229212
additional storage. */
230213
void EnsureSpace(size_t min_size) {
231-
assert(this);
232214
assert(Storage.empty() || (ItemOffset < Storage.size()));
233215
assert(ItemCount <= (Storage.size() - ItemOffset));
234216
size_t actual = SpaceSize();
@@ -242,7 +224,6 @@ namespace Base {
242224
items the buffer can hold is at least 'min_size'. If necessary, move
243225
items to front of buffer and possibly allocate additional storage. */
244226
void EnsureDataPlusSpace(size_t min_size) {
245-
assert(this);
246227
assert(Storage.empty() || (ItemOffset < Storage.size()));
247228
assert(ItemCount <= (Storage.size() - ItemOffset));
248229
size_t actual = Storage.size() - ItemOffset;
@@ -257,7 +238,6 @@ namespace Base {
257238
consumed. This increases the value returned by DataSize() and decreases
258239
the value returned by SpaceSize(). */
259240
void MarkSpaceConsumed(size_t size) noexcept {
260-
assert(this);
261241
assert(Storage.empty() || (ItemOffset < Storage.size()));
262242
assert(ItemCount <= (Storage.size() - ItemOffset));
263243
assert(size <= SpaceSize());
@@ -270,7 +250,6 @@ namespace Base {
270250
available space indicated by SpaceSize() follows the unconsumed items,
271251
and consuming items makes space available at the front. */
272252
void MarkDataConsumed(size_t size) noexcept {
273-
assert(this);
274253
assert(Storage.empty() || (ItemOffset < Storage.size()));
275254
assert(ItemCount <= (Storage.size() - ItemOffset));
276255
assert(size <= DataSize());
@@ -284,7 +263,6 @@ namespace Base {
284263

285264
private:
286265
void DoAddSpace(size_t min_to_add) {
287-
assert(this);
288266
assert(min_to_add);
289267
assert(Storage.empty() || (ItemOffset < Storage.size()));
290268
assert(ItemCount <= (Storage.size() - ItemOffset));

src/base/code_location.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
using namespace Base;
2727

2828
const char *TCodeLocation::GetFile() const noexcept {
29-
assert(this);
3029
return File + ((std::strncmp(File, SrcRoot, SrcRootLen) == 0) ?
3130
(SrcRootLen) : 0);
3231
}
3332

3433
void TCodeLocation::Write(std::ostream &strm) const {
35-
assert(this);
3634
strm << '[' << GetFile() << ", " << LineNumber << ']';
3735
}
3836

src/base/code_location.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ namespace Base {
6767

6868
/* Returns the line number. Always returns > 0. */
6969
unsigned GetLineNumber() const {
70-
assert(this);
7170
return LineNumber;
7271
}
7372

src/base/convert.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ namespace Base {
3838
the next character at the head of the input stream, it returns
3939
TOpt::Unknown. */
4040
TOpt<bool> TryReadSign() {
41-
assert(this);
42-
4341
if(!(*this)) {
4442
return *TOpt<bool>::Unknown;
4543
}
@@ -60,7 +58,6 @@ namespace Base {
6058

6159
/* TryReadSign wrapper that asserts that a sign is read or throws. */
6260
bool ReadSign() {
63-
assert(this);
6461
TOpt<bool> ret = TryReadSign();
6562

6663
if (ret) {
@@ -73,20 +70,16 @@ namespace Base {
7370
/* Returns true if there is a next character in the input stream and it is
7471
a digit, false otherwise. */
7572
bool HasDigit() {
76-
assert(this);
7773
return ((*this) && isdigit(*(*this)));
7874
}
7975

8076
void ConsumeWhitespace() {
81-
assert(this);
8277
while(isspace(**this)) { ++(*this); }
8378
}
8479

8580
/* Reads in a character from Input and converts it to it's decimal value.
8681
*/
8782
template<typename TVal> bool TryReadDigit(TVal &output) {
88-
assert(this);
89-
assert(&output);
9083
assert(std::numeric_limits<TVal>::is_exact);
9184
assert(std::numeric_limits<TVal>::min() <= 0);
9285
assert(std::numeric_limits<TVal>::max() >= 9);
@@ -109,8 +102,6 @@ namespace Base {
109102
bounds checking. */
110103
template<typename TVal> bool TryReadUnsignedInt(TVal &output,
111104
bool positive = true) {
112-
assert(this);
113-
assert(&output);
114105
assert(std::numeric_limits<TVal>::is_integer);
115106
assert(std::numeric_limits<TVal>::is_exact);
116107
assert(positive || std::numeric_limits<TVal>::is_signed);
@@ -165,8 +156,6 @@ namespace Base {
165156
read or an exception thrown. */
166157
template <typename TVal>
167158
TConverter &ReadUnsignedInt(TVal &output, bool positive=true) {
168-
assert(this);
169-
170159
if (!TryReadUnsignedInt(output, positive)) {
171160
throw TSyntaxError(HERE,
172161
"No integer exists at current location in stream.");
@@ -187,8 +176,6 @@ namespace Base {
187176
support hexadecimal and octal. */
188177
template <typename TVal>
189178
bool TryReadInt(TVal &output, bool sign_required = false) {
190-
assert(this);
191-
assert(&output);
192179
assert(std::numeric_limits<TVal>::is_integer);
193180
assert(std::numeric_limits<TVal>::is_exact);
194181
assert(sign_required ? std::numeric_limits<TVal>::is_signed : true);
@@ -219,8 +206,6 @@ namespace Base {
219206
at the current stream head, then an exception should be thrown. */
220207
template <typename TVal>
221208
TConverter &ReadInt(TVal &output, bool sign_required = false) {
222-
assert(this);
223-
224209
if (!TryReadInt(output, sign_required)) {
225210
throw TSyntaxError(HERE, "No integer exists at current location.");
226211
}
@@ -241,7 +226,6 @@ namespace Base {
241226
void ReadDouble(double &output, bool sign_required=false);
242227

243228
operator bool() const {
244-
assert(this);
245229
return Working;
246230
}
247231

@@ -267,8 +251,6 @@ namespace Base {
267251
}
268252

269253
TConverter &operator++() {
270-
assert(this);
271-
272254
if (!Working) {
273255
throw TSyntaxError(HERE, "unexpectedly out of text");
274256
}

src/base/counter.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,33 +100,28 @@ namespace Base {
100100

101101
/* The code location at which the counter was declared. */
102102
const Base::TCodeLocation &GetCodeLocation() const noexcept {
103-
assert(this);
104103
return CodeLocation;
105104
}
106105

107106
/* The count as of the last time the counters were sampled. */
108107
uint32_t GetCount() const noexcept {
109-
assert(this);
110108
return SampledCount;
111109
}
112110

113111
/* The name of this counter. This should be unique within its module.
114112
Never null. */
115113
const char *GetName() const noexcept {
116-
assert(this);
117114
return Name;
118115
}
119116

120117
/* The next counter in the program, if any. */
121118
const TCounter *GetNextCounter() const noexcept {
122-
assert(this);
123119
return NextCounter;
124120
}
125121

126122
/* Increment the counter. This will not change the current frozen value,
127123
but will be reflected in the next frozen value. */
128124
void Increment(uint32_t delta = 1) noexcept {
129-
assert(this);
130125
Base::TSharedLock<Base::TBlockingAsset> lock(Asset);
131126
__sync_add_and_fetch(&UnsampledCount, delta);
132127
}

src/base/demangle.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ TDemangle::TDemangle(const char *mangled) : Buf(nullptr) {
3636
}
3737

3838
TDemangle::~TDemangle() {
39-
assert(this);
4039
assert(Buf);
4140
free(Buf); //The gcc man pages use free, so we use free.
4241
}
4342

4443
const char *TDemangle::Get() const {
45-
assert(this);
4644
assert(Buf);
4745
return Buf;
4846
}

src/base/dir_iter.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,15 @@ TDirIter::TDirIter(const char *dir)
3636
}
3737

3838
TDirIter::~TDirIter() {
39-
assert(this);
4039
Wr::closedir(Handle);
4140
}
4241

4342
void TDirIter::Rewind() noexcept {
44-
assert(this);
4543
rewinddir(Handle);
4644
Pos = NotFresh;
4745
}
4846

4947
bool TDirIter::TryRefresh() const noexcept {
50-
assert(this);
51-
5248
while (Pos == NotFresh) {
5349
dirent *const ptr = Wr::readdir(Handle);
5450

0 commit comments

Comments
 (0)