]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: remove invalid comparisons of 'this' with NULL
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 21 Nov 2014 18:14:10 +0000 (10:14 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 21 Nov 2014 18:14:10 +0000 (10:14 -0800)
... which are invalid in C++ and always equate (this!=NULL) to true.

Clang 3.5 refuses to build code containing these invalid comparisons.

include/splay.h
lib/MemPoolChunked.cc
src/HttpHdrRange.cc
src/String.cc
src/auth/UserRequest.cc
src/auth/negotiate/UserRequest.cc
src/auth/ntlm/UserRequest.cc
src/client_side.cc
src/fs/ufs/RebuildState.cc
src/store.cc

index eae7380d33f3d8039dd854f06b74f95b4f0b2623..9b83b6d7f79c2a31e3eba285c5b03275f0925ac2 100644 (file)
@@ -32,7 +32,7 @@ public:
     mutable SplayNode<V> *right;
     void destroy(SPLAYFREE *);
     void walk(SPLAYWALKEE *, void *callerState);
-    bool empty() const { return this == NULL; }
+    bool empty() const {return false;}
     SplayNode<V> const * start() const;
     SplayNode<V> const * finish() const;
 
@@ -110,9 +110,6 @@ template<class V>
 void
 SplayNode<V>::walk(SPLAYWALKEE * walkee, void *state)
 {
-    if (this == NULL)
-        return;
-
     if (left)
         left->walk(walkee, state);
 
@@ -126,7 +123,7 @@ template<class V>
 SplayNode<V> const *
 SplayNode<V>::start() const
 {
-    if (this && left)
+    if (left)
         return left->start();
 
     return this;
@@ -136,7 +133,7 @@ template<class V>
 SplayNode<V> const *
 SplayNode<V>::finish() const
 {
-    if (this && right)
+    if (right)
         return right->finish();
 
     return this;
@@ -146,9 +143,6 @@ template<class V>
 void
 SplayNode<V>::destroy(SPLAYFREE * free_func)
 {
-    if (!this)
-        return;
-
     if (left)
         left->destroy(free_func);
 
@@ -164,9 +158,6 @@ template<class V>
 SplayNode<V> *
 SplayNode<V>::remove(Value const dataToRemove, SPLAYCMP * compare)
 {
-    if (this == NULL)
-        return NULL;
-
     SplayNode<V> *result = splay(dataToRemove, compare);
 
     if (splayLastResult == 0) {        /* found it */
@@ -195,12 +186,6 @@ SplayNode<V>::insert(Value dataToInsert, SPLAYCMP * compare)
     /* create node to insert */
     SplayNode<V> *newNode = new SplayNode<V>(dataToInsert);
 
-    if (this == NULL) {
-        splayLastResult = -1;
-        newNode->left = newNode->right = NULL;
-        return newNode;
-    }
-
     SplayNode<V> *newTop = splay(dataToInsert, compare);
 
     if (splayLastResult < 0) {
@@ -225,12 +210,6 @@ template<class FindValue>
 SplayNode<V> *
 SplayNode<V>::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<V> N(temp);
     SplayNode<V> *l;
index 2c882327c29bcf5eb5525d4f26cc78c48cef977f..89ba20c9eb4535465fda0d333085a2cf2b904473 100644 (file)
@@ -367,8 +367,6 @@ MemPoolChunked::clean(time_t maxage)
     MemChunk *chunk, *freechunk, *listTail;
     time_t age;
 
-    if (!this)
-        return;
     if (!Chunks)
         return;
 
index 7b93bfd69719bb1332f2383a08e6a21fa3b3f658..0df454a2860833549c334d6ee9ce27d6488e6bcf 100644 (file)
@@ -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<HttpHdrRangeSpec *> &copy)
 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;
index fc61140625f0183ab973d0a964c08ddfb1ea437e..0e0a0d90e716b80354118ce3519d1bae76a44a01 100644 (file)
@@ -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);
index bdebf7db2ed1e280d062e167f57462c13d5f5149..78b07e46bb5d2dd7f3e60605a67b65c5fd61293b 100644 (file)
@@ -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();
 }
index 54aa9ecaf8c91c34f4b79ae0412e71a96e94f31b..6575f5a6d91ba0f7686a685c8856284980208fe2 100644 (file)
@@ -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 */
 
index 9f68d3166a98080cf0ecbc2ae67ff60048b6bf7a..c73cfa83f85ed6972b621945761773b5e7e5272f 100644 (file)
@@ -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 */
 
index 486b4de846510a54967c2ac3e802249e3c96a3fb..32403ccd844daf507ad57f3d7e94ac31b529d51e 100644 (file)
@@ -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);
index 0bb04e330b950f119de6f05a3eefc0046ace5d43..54efaec20feff7e2a33f0e38c31cbde0b69551ed 100644 (file)
@@ -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);
index 48cde8057a9425d30b142411639c2cba5e8a9ca2..e75bf67e1024208d6f7e56613109b7c2865092a8 100644 (file)
@@ -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();