From: Amos Jeffries Date: Fri, 21 Nov 2014 18:14:10 +0000 (-0800) Subject: Cleanup: remove invalid comparisons of 'this' with NULL X-Git-Tag: merge-candidate-3-v1~474 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=328a07ab3c8cf73c748d99fb05fc5355b1c2f40c;p=thirdparty%2Fsquid.git Cleanup: remove invalid comparisons of 'this' with NULL ... which are invalid in C++ and always equate (this!=NULL) to true. Clang 3.5 refuses to build code containing these invalid comparisons. --- diff --git a/include/splay.h b/include/splay.h index eae7380d33..9b83b6d7f7 100644 --- a/include/splay.h +++ b/include/splay.h @@ -32,7 +32,7 @@ public: mutable SplayNode *right; void destroy(SPLAYFREE *); void walk(SPLAYWALKEE *, void *callerState); - bool empty() const { return this == NULL; } + bool empty() const {return false;} SplayNode const * start() const; SplayNode const * finish() const; @@ -110,9 +110,6 @@ template void SplayNode::walk(SPLAYWALKEE * walkee, void *state) { - if (this == NULL) - return; - if (left) left->walk(walkee, state); @@ -126,7 +123,7 @@ template SplayNode const * SplayNode::start() const { - if (this && left) + if (left) return left->start(); return this; @@ -136,7 +133,7 @@ template SplayNode const * SplayNode::finish() const { - if (this && right) + if (right) return right->finish(); return this; @@ -146,9 +143,6 @@ template void SplayNode::destroy(SPLAYFREE * free_func) { - if (!this) - return; - if (left) left->destroy(free_func); @@ -164,9 +158,6 @@ template SplayNode * SplayNode::remove(Value const dataToRemove, SPLAYCMP * compare) { - if (this == NULL) - return NULL; - SplayNode *result = splay(dataToRemove, compare); if (splayLastResult == 0) { /* found it */ @@ -195,12 +186,6 @@ SplayNode::insert(Value dataToInsert, SPLAYCMP * compare) /* create node to insert */ SplayNode *newNode = new SplayNode(dataToInsert); - if (this == NULL) { - splayLastResult = -1; - newNode->left = newNode->right = NULL; - return newNode; - } - SplayNode *newTop = splay(dataToInsert, compare); if (splayLastResult < 0) { @@ -225,12 +210,6 @@ template SplayNode * SplayNode::splay(FindValue const &dataToFind, int( * compare)(FindValue const &a, Value const &b)) const { - if (this == NULL) { - /* can't have compared successfully :} */ - splayLastResult = -1; - return NULL; - } - Value temp = Value(); SplayNode N(temp); SplayNode *l; diff --git a/lib/MemPoolChunked.cc b/lib/MemPoolChunked.cc index 2c882327c2..89ba20c9eb 100644 --- a/lib/MemPoolChunked.cc +++ b/lib/MemPoolChunked.cc @@ -367,8 +367,6 @@ MemPoolChunked::clean(time_t maxage) MemChunk *chunk, *freechunk, *listTail; time_t age; - if (!this) - return; if (!Chunks) return; diff --git a/src/HttpHdrRange.cc b/src/HttpHdrRange.cc index 7b93bfd697..0df454a286 100644 --- a/src/HttpHdrRange.cc +++ b/src/HttpHdrRange.cc @@ -224,7 +224,7 @@ HttpHdrRange::parseInit(const String * range_spec) const char *item; const char *pos = NULL; int ilen; - assert(this && range_spec); + assert(range_spec); ++ParsedCount; debugs(64, 8, "parsing range field: '" << range_spec << "'"); /* check range type */ @@ -306,7 +306,6 @@ void HttpHdrRange::packInto(Packer * packer) const { const_iterator pos = begin(); - assert(this); while (pos != end()) { if (pos != begin()) @@ -371,7 +370,7 @@ HttpHdrRange::getCanonizedSpecs(std::vector ©) int HttpHdrRange::canonize(HttpReply *rep) { - assert(this && rep); + assert(rep); if (rep->content_range) clen = rep->content_range->elength; @@ -401,7 +400,6 @@ bool HttpHdrRange::isComplex() const { int64_t offset = 0; - assert(this); /* check that all rangers are in "strong" order */ const_iterator pos (begin()); @@ -427,7 +425,6 @@ HttpHdrRange::isComplex() const bool HttpHdrRange::willBeComplex() const { - assert(this); /* check that all rangers are in "strong" order, */ /* as far as we can tell without the content length */ int64_t offset = 0; @@ -460,7 +457,6 @@ int64_t HttpHdrRange::firstOffset() const { int64_t offset = HttpHdrRangeSpec::UnknownPosition; - assert(this); const_iterator pos = begin(); while (pos != end()) { @@ -484,7 +480,6 @@ HttpHdrRange::lowestOffset(int64_t size) const { int64_t offset = HttpHdrRangeSpec::UnknownPosition; const_iterator pos = begin(); - assert(this); while (pos != end()) { int64_t current = (*pos)->offset; @@ -512,10 +507,6 @@ HttpHdrRange::lowestOffset(int64_t size) const bool HttpHdrRange::offsetLimitExceeded(const int64_t limit) const { - if (NULL == this) - /* not a range request */ - return false; - if (limit == 0) /* 0 == disabled */ return true; diff --git a/src/String.cc b/src/String.cc index fc61140625..0e0a0d90e7 100644 --- a/src/String.cc +++ b/src/String.cc @@ -105,7 +105,7 @@ void String::allocAndFill(const char *str, int len) { PROF_start(StringAllocAndFill); - assert(this && str); + assert(str); allocBuffer(len + 1); len_ = len; memcpy(buf_, str, len); @@ -127,7 +127,6 @@ void String::clean() { PROF_start(StringClean); - assert(this); /* TODO if mempools has already closed this will FAIL!! */ if (defined()) @@ -163,7 +162,6 @@ String::reset(char const *str) void String::append( char const *str, int len) { - assert(this); assert(str && len >= 0); PROF_start(StringAppend); diff --git a/src/auth/UserRequest.cc b/src/auth/UserRequest.cc index bdebf7db2e..78b07e46bb 100644 --- a/src/auth/UserRequest.cc +++ b/src/auth/UserRequest.cc @@ -124,9 +124,8 @@ Auth::UserRequest::getDenyMessage() char const * Auth::UserRequest::denyMessage(char const * const default_message) { - if (this == NULL || getDenyMessage() == NULL) { + if (getDenyMessage() == NULL) return default_message; - } return getDenyMessage(); } diff --git a/src/auth/negotiate/UserRequest.cc b/src/auth/negotiate/UserRequest.cc index 54aa9ecaf8..6575f5a6d9 100644 --- a/src/auth/negotiate/UserRequest.cc +++ b/src/auth/negotiate/UserRequest.cc @@ -163,8 +163,6 @@ Auth::Negotiate::UserRequest::releaseAuthServer() void Auth::Negotiate::UserRequest::authenticate(HttpRequest * aRequest, ConnStateData * conn, http_hdr_type type) { - assert(this); - /* Check that we are in the client side, where we can generate * auth challenges */ diff --git a/src/auth/ntlm/UserRequest.cc b/src/auth/ntlm/UserRequest.cc index 9f68d3166a..c73cfa83f8 100644 --- a/src/auth/ntlm/UserRequest.cc +++ b/src/auth/ntlm/UserRequest.cc @@ -157,8 +157,6 @@ Auth::Ntlm::UserRequest::releaseAuthServer() void Auth::Ntlm::UserRequest::authenticate(HttpRequest * aRequest, ConnStateData * conn, http_hdr_type type) { - assert(this); - /* Check that we are in the client side, where we can generate * auth challenges */ diff --git a/src/client_side.cc b/src/client_side.cc index 486b4de846..32403ccd84 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -688,7 +688,6 @@ httpRequestFree(void *data) bool ConnStateData::areAllContextsForThisConnection() const { - assert(this != NULL); ClientSocketContext::Pointer context = getCurrentContext(); while (context.getRaw()) { @@ -844,7 +843,6 @@ ConnStateData::isOpen() const ConnStateData::~ConnStateData() { - assert(this != NULL); debugs(33, 3, HERE << clientConnection); if (isOpen()) @@ -924,7 +922,6 @@ connIsUsable(ConnStateData * conn) ClientSocketContext::Pointer ConnStateData::getCurrentContext() const { - assert(this); return currentobject; } @@ -1255,7 +1252,6 @@ clientIfRangeMatch(ClientHttpRequest * http, HttpReply * rep) String ClientHttpRequest::rangeBoundaryStr() const { - assert(this); const char *key; String b(APP_FULLNAME); b.append(":",1); diff --git a/src/fs/ufs/RebuildState.cc b/src/fs/ufs/RebuildState.cc index 0bb04e330b..54efaec20f 100644 --- a/src/fs/ufs/RebuildState.cc +++ b/src/fs/ufs/RebuildState.cc @@ -130,7 +130,6 @@ Fs::Ufs::RebuildState::rebuildFromDirectory() struct stat sb; int fd = -1; - assert(this != NULL); debugs(47, 3, HERE << "DIR #" << sd->index); assert(fd == -1); diff --git a/src/store.cc b/src/store.cc index 48cde8057a..e75bf67e10 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1668,9 +1668,7 @@ StoreEntry::setMemStatus(mem_status_t new_status) const char * StoreEntry::url() const { - if (this == NULL) - return "[null_entry]"; - else if (mem_obj == NULL) + if (mem_obj == NULL) return "[null_mem_obj]"; else return mem_obj->storeId();