]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Refactor type of some flags to bool
authorFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 25 Jan 2013 16:53:16 +0000 (17:53 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 25 Jan 2013 16:53:16 +0000 (17:53 +0100)
Affected classes: StoreClient, mem_node, AclUserData, AclMaxUserIp,
Auth::Digest::UserRequest, digest_nonce_h

14 files changed:
src/StoreClient.h
src/acl/UserData.cc
src/acl/UserData.h
src/auth/AclMaxUserIp.cc
src/auth/AclMaxUserIp.h
src/auth/digest/UserRequest.cc
src/auth/digest/UserRequest.h
src/auth/digest/auth_digest.cc
src/auth/digest/auth_digest.h
src/mem_node.cc
src/mem_node.h
src/stmem.cc
src/store_client.cc
src/urn.cc

index e6f1001f507be9c4f066595f89a6d19fec11f0c0..9264c6fd7442bcc1da8d93c5f0a8d014f2b2ad9e 100644 (file)
@@ -83,9 +83,9 @@ public:
     StoreIOState::Pointer swapin_sio;
 
     struct {
-        unsigned int disk_io_pending:1;
-        unsigned int store_copying:1;
-        unsigned int copy_event_pending:1;
+        bool disk_io_pending;
+        bool store_copying;
+        bool copy_event_pending;
     } flags;
 
 #if USE_DELAY_POOLS
index 0579f5aff025711504ce56880032189564ffeefd..e023f3b11311a0b3b1a3ccd78c9767c138dd3186 100644 (file)
@@ -132,10 +132,10 @@ ACLUserData::parse()
 
         if (strcmp("-i", t) == 0) {
             debugs(28, 5, "aclParseUserList: Going case-insensitive");
-            flags.case_insensitive = 1;
+            flags.case_insensitive = true;
         } else if (strcmp("REQUIRED", t) == 0) {
             debugs(28, 5, "aclParseUserList: REQUIRED-type enabled");
-            flags.required = 1;
+            flags.required = true;
         } else {
             if (flags.case_insensitive)
                 Tolower(t);
index e5d0d4d70c11e08f503dec58ad401beffa2d7afc..39e6374907fa0646f38618e7b524e4c5a021e238 100644 (file)
@@ -53,8 +53,8 @@ public:
     SplayNode<char *> *names;
 
     struct {
-        unsigned int case_insensitive:1;
-        unsigned int required:1;
+        bool case_insensitive;
+        bool required;
     } flags;
 };
 
index ddb6b054a91478b201a843f007dd16919c26c83b..e297ddad124257a51b745fc0aacd02bd246bb8d5 100644 (file)
@@ -63,7 +63,7 @@ ACLMaxUserIP::parse()
 
     if (strcmp("-s", t) == 0) {
         debugs(28, 5, "aclParseUserMaxIP: Going strict");
-        flags.strict = 1;
+        flags.strict = true;
         t = ConfigParser::strtokFile();
     }
 
index 82913e2510d9613bf6b23b49091f9a4be5fa3f09..5d5e962b1cd29458997e88df1a4d0ebe36f07c09 100644 (file)
@@ -73,9 +73,9 @@ private:
     int maximum;
 
     struct Flags {
-        Flags() : strict(0) {}
+        Flags() : strict(false) {}
 
-        unsigned int strict:1;
+        bool strict;
     } flags;
 };
 
index fbbb43069ec869a540b6f23ac363aae9117de137..f1059aa05a6cd9c31b08e3d8ee461ae58d31c3bc 100644 (file)
@@ -102,7 +102,7 @@ Auth::Digest::UserRequest::authenticate(HttpRequest * request, ConnStateData * c
     if (strcasecmp(digest_request->response, Response) != 0) {
         if (!digest_request->flags.helper_queried) {
             /* Query the helper in case the password has changed */
-            digest_request->flags.helper_queried = 1;
+            digest_request->flags.helper_queried = true;
             auth_user->credentials(Auth::Pending);
             return;
         }
@@ -120,7 +120,7 @@ Auth::Digest::UserRequest::authenticate(HttpRequest * request, ConnStateData * c
 
             if (strcasecmp(digest_request->response, Response)) {
                 auth_user->credentials(Auth::Failed);
-                digest_request->flags.invalid_password = 1;
+                digest_request->flags.invalid_password = true;
                 digest_request->setDenyMessage("Incorrect password");
                 return;
             } else {
@@ -145,7 +145,7 @@ Auth::Digest::UserRequest::authenticate(HttpRequest * request, ConnStateData * c
             }
         } else {
             auth_user->credentials(Auth::Failed);
-            digest_request->flags.invalid_password = 1;
+            digest_request->flags.invalid_password = true;
             digest_request->setDenyMessage("Incorrect password");
             return;
         }
@@ -214,7 +214,7 @@ Auth::Digest::UserRequest::addAuthenticationInfoHeader(HttpReply * rep, int acce
 #endif
 
     if ((static_cast<Auth::Digest::Config*>(Auth::Config::Find("digest"))->authenticateProgram) && authDigestNonceLastRequest(nonce)) {
-        flags.authinfo_sent = 1;
+        flags.authinfo_sent = true;
         debugs(29, 9, HERE << "Sending type:" << type << " header: 'nextnonce=\"" << authenticateDigestNonceNonceb64(nonce) << "\"");
         httpHeaderPutStrf(&rep->header, type, "nextnonce=\"%s\"", authenticateDigestNonceNonceb64(nonce));
     }
@@ -331,7 +331,7 @@ Auth::Digest::UserRequest::HandleReply(void *data, const HelperReply &reply)
         assert(digest_request);
 
         digest_request->user()->credentials(Auth::Failed);
-        digest_request->flags.invalid_password = 1;
+        digest_request->flags.invalid_password = true;
 
         Note::Pointer msgNote = reply.notes.find("message");
         if (msgNote != NULL) {
index 011be30dab5044510d09d2a9c677f26eb92b9c26..6c328ed933ed2100f884da4ba37c7df634ef4828 100644 (file)
@@ -48,9 +48,9 @@ public:
     char *response;
 
     struct {
-        unsigned int authinfo_sent:1;
-        unsigned int invalid_password:1;
-        unsigned int helper_queried:1;
+        bool authinfo_sent;
+        bool invalid_password;
+        bool helper_queried;
     } flags;
     digest_nonce_h *nonce;
 
index 112b3d4904886e2d2dfcee5af90ff30bcd5d8aa9..7f47df99b17acff9f03debbb71bf498dcc5f32c8 100644 (file)
@@ -171,7 +171,7 @@ authenticateDigestNonceNew(void)
 
     /* create a new nonce */
     newnonce->nc = 0;
-    newnonce->flags.valid = 1;
+    newnonce->flags.valid = true;
     newnonce->noncedata.self = newnonce;
     newnonce->noncedata.creationtime = current_time.tv_sec;
     newnonce->noncedata.randomdata = squid_random();
@@ -193,7 +193,7 @@ authenticateDigestNonceNew(void)
     hash_join(digest_nonce_cache, newnonce);
     /* the cache's link */
     authDigestNonceLink(newnonce);
-    newnonce->flags.incache = 1;
+    newnonce->flags.incache = true;
     debugs(29, 5, "authenticateDigestNonceNew: created nonce " << newnonce << " at " << newnonce->noncedata.creationtime);
     return newnonce;
 }
@@ -210,7 +210,7 @@ authenticateDigestNonceDelete(digest_nonce_h * nonce)
 
 #endif
 
-        assert(nonce->flags.incache == 0);
+        assert(!nonce->flags.incache);
 
         safe_free(nonce->key);
 
@@ -281,7 +281,7 @@ authenticateDigestNonceCacheCleanup(void *data)
             debugs(29, 4, "authenticateDigestNonceCacheCleanup: Removing nonce " << (char *) nonce->key << " from cache due to timeout.");
             assert(nonce->flags.incache);
             /* invalidate nonce so future requests fail */
-            nonce->flags.valid = 0;
+            nonce->flags.valid = false;
             /* if it is tied to a auth_user, remove the tie */
             authDigestNonceUserUnlink(nonce);
             authDigestNoncePurge(nonce);
@@ -386,7 +386,7 @@ authDigestNonceIsValid(digest_nonce_h * nonce, char nc[9])
     if ((static_cast<Auth::Digest::Config*>(Auth::Config::Find("digest"))->NonceStrictness && intnc != nonce->nc + 1) ||
             intnc < nonce->nc + 1) {
         debugs(29, 4, "authDigestNonceIsValid: Nonce count doesn't match");
-        nonce->flags.valid = 0;
+        nonce->flags.valid = false;
         return 0;
     }
 
@@ -414,19 +414,19 @@ authDigestNonceIsStale(digest_nonce_h * nonce)
                static_cast<Auth::Digest::Config*>(Auth::Config::Find("digest"))->noncemaxduration << " " <<
                current_time.tv_sec);
 
-        nonce->flags.valid = 0;
+        nonce->flags.valid = false;
         return -1;
     }
 
     if (nonce->nc > 99999998) {
         debugs(29, 4, "authDigestNonceIsStale: Nonce count overflow");
-        nonce->flags.valid = 0;
+        nonce->flags.valid = false;
         return -1;
     }
 
     if (nonce->nc > static_cast<Auth::Digest::Config*>(Auth::Config::Find("digest"))->noncemaxuses) {
         debugs(29, 4, "authDigestNoncelastRequest: Nonce count over user limit");
-        nonce->flags.valid = 0;
+        nonce->flags.valid = false;
         return -1;
     }
 
@@ -469,7 +469,7 @@ authDigestNoncePurge(digest_nonce_h * nonce)
 
     hash_remove_link(digest_nonce_cache, nonce);
 
-    nonce->flags.incache = 0;
+    nonce->flags.incache = false;
 
     /* the cache's link */
     authDigestNonceUnlink(nonce);
index fc24aba0e8800b083fe10d55bdd07c21e11d06a3..1b3892d61854669eb328f762ead6f1ce21b0b6a1 100644 (file)
@@ -45,8 +45,8 @@ struct _digest_nonce_h : public hash_link {
     /* has this nonce been invalidated ? */
 
     struct {
-        unsigned int valid:1;
-        unsigned int incache:1;
+        bool valid;
+        bool incache;
     } flags;
 };
 
index dc59c3049f303ac74c423d0c2b6dba0cfb222b92..d79aa2129bfcd8d8e81df0bbbc95e8e9f8a45769 100644 (file)
@@ -60,12 +60,12 @@ memNodeWriteComplete(void* d)
 {
     mem_node* n = (mem_node*)((char*)d - _mem_node_data_offset);
     assert(n->write_pending);
-    n->write_pending = 0;
+    n->write_pending = false;
 }
 
 mem_node::mem_node(int64_t offset) :
         nodeBuffer(0,offset,data),
-        write_pending(0)
+        write_pending(false)
 {
     *data = 0;
 }
index a01765ec2b9d07de04637cdfa205db04d0209f14..214028caeeb68ec89158142be6d37bd3fb0d7f55 100644 (file)
@@ -58,7 +58,7 @@ public:
     StoreIOBuffer nodeBuffer;
     /* Private */
     char data[SM_PAGE_SIZE];
-    unsigned int write_pending:1;
+    bool write_pending;
 };
 
 MEMPROXY_CLASS_INLINE(mem_node);
index 1465a9fbe770a1777227767bd3eb37d972404857..c00aa436ba6ab585faeee5a3e9475fa28aa7f881 100644 (file)
@@ -50,7 +50,7 @@ char *
 mem_hdr::NodeGet(mem_node * aNode)
 {
     assert(!aNode->write_pending);
-    aNode->write_pending = 1;
+    aNode->write_pending = true;
     return aNode->data;
 }
 
index 15c1e9462c0522877729f2d4ea72c6cbdf9003fa..56ce3c6d45140333212de2494841752de7bf94a3 100644 (file)
@@ -175,7 +175,7 @@ storeClientCopyEvent(void *data)
     store_client *sc = (store_client *)data;
     debugs(90, 3, "storeClientCopyEvent: Running");
     assert (sc->flags.copy_event_pending);
-    sc->flags.copy_event_pending = 0;
+    sc->flags.copy_event_pending = false;
 
     if (!sc->_callback.pending())
         return;
@@ -191,7 +191,7 @@ store_client::store_client(StoreEntry *e) : entry (e)
         ,  object_ok(true)
 {
     cmp_offset = 0;
-    flags.disk_io_pending = 0;
+    flags.disk_io_pending = false;
     ++ entry->refcount;
 
     if (getType() == STORE_DISK_CLIENT)
@@ -315,7 +315,7 @@ storeClientCopy2(StoreEntry * e, store_client * sc)
     }
 
     if (sc->flags.store_copying) {
-        sc->flags.copy_event_pending = 1;
+        sc->flags.copy_event_pending = true;
         debugs(90, 3, "storeClientCopy2: Queueing storeClientCopyEvent()");
         eventAdd("storeClientCopyEvent", storeClientCopyEvent, sc, 0.0, 0);
         return;
@@ -335,9 +335,9 @@ storeClientCopy2(StoreEntry * e, store_client * sc)
      * this function
      */
     cbdataInternalLock(sc);
-    assert (sc->flags.store_copying == 0);
+    assert (!sc->flags.store_copying);
     sc->doCopy(e);
-    assert (sc->flags.store_copying == 0);
+    assert (!sc->flags.store_copying);
     cbdataInternalUnlock(sc);
 }
 
@@ -345,7 +345,7 @@ void
 store_client::doCopy(StoreEntry *anEntry)
 {
     assert (anEntry == entry);
-    flags.store_copying = 1;
+    flags.store_copying = true;
     MemObject *mem = entry->mem_obj;
 
     debugs(33, 5, "store_client::doCopy: co: " <<
@@ -356,14 +356,14 @@ store_client::doCopy(StoreEntry *anEntry)
         /* There is no more to send! */
         debugs(33, 3, HERE << "There is no more to send!");
         callback(0);
-        flags.store_copying = 0;
+        flags.store_copying = false;
         return;
     }
 
     /* Check that we actually have data */
     if (anEntry->store_status == STORE_PENDING && copyInto.offset >= mem->endOffset()) {
         debugs(90, 3, "store_client::doCopy: Waiting for more");
-        flags.store_copying = 0;
+        flags.store_copying = false;
         return;
     }
 
@@ -394,7 +394,7 @@ store_client::startSwapin()
     if (storeTooManyDiskFilesOpen()) {
         /* yuck -- this causes a TCP_SWAPFAIL_MISS on the client side */
         fail();
-        flags.store_copying = 0;
+        flags.store_copying = false;
         return;
     } else if (!flags.disk_io_pending) {
         /* Don't set store_io_pending here */
@@ -402,7 +402,7 @@ store_client::startSwapin()
 
         if (swapin_sio == NULL) {
             fail();
-            flags.store_copying = 0;
+            flags.store_copying = false;
             return;
         }
 
@@ -415,7 +415,7 @@ store_client::startSwapin()
         return;
     } else {
         debugs(90, DBG_IMPORTANT, "WARNING: Averted multiple fd operation (1)");
-        flags.store_copying = 0;
+        flags.store_copying = false;
         return;
     }
 }
@@ -443,7 +443,7 @@ store_client::scheduleDiskRead()
 
     fileRead();
 
-    flags.store_copying = 0;
+    flags.store_copying = false;
 }
 
 void
@@ -454,7 +454,7 @@ store_client::scheduleMemRead()
     debugs(90, 3, "store_client::doCopy: Copying normal from memory");
     size_t sz = entry->mem_obj->data_hdr.copy(copyInto);
     callback(sz);
-    flags.store_copying = 0;
+    flags.store_copying = false;
 }
 
 void
@@ -464,7 +464,7 @@ store_client::fileRead()
 
     assert(_callback.pending());
     assert(!flags.disk_io_pending);
-    flags.disk_io_pending = 1;
+    flags.disk_io_pending = true;
 
     if (mem->swap_hdr_sz != 0)
         if (entry->swap_status == SWAPOUT_WRITING)
@@ -491,7 +491,7 @@ store_client::readBody(const char *buf, ssize_t len)
     int parsed_header = 0;
 
     // Don't assert disk_io_pending here.. may be called by read_header
-    flags.disk_io_pending = 0;
+    flags.disk_io_pending = false;
     assert(_callback.pending());
     debugs(90, 3, "storeClientReadBody: len " << len << "");
 
@@ -615,7 +615,7 @@ store_client::readHeader(char const *buf, ssize_t len)
     MemObject *const mem = entry->mem_obj;
 
     assert(flags.disk_io_pending);
-    flags.disk_io_pending = 0;
+    flags.disk_io_pending = false;
     assert(_callback.pending());
 
     unpackHeader (buf, len);
index e9967443b694c50710c71b914982212cce6135f2..cf4ce339f3219db960cebe76e90fedce6f780da3 100644 (file)
@@ -72,7 +72,7 @@ public:
     HttpRequest *urlres_r;
 
     struct {
-        unsigned int force_menu:1;
+        bool force_menu;
     } flags;
     char reqbuf[URN_REQBUF_SZ];
     int reqofs;
@@ -216,7 +216,7 @@ UrnState::setUriResFromRequest(HttpRequest *r)
 {
     if (RequestNeedsMenu(r)) {
         updateRequestURL(r, r->urlpath.rawBuf() + 5, r->urlpath.size() - 5 );
-        flags.force_menu = 1;
+        flags.force_menu = true;
     }
 
     createUriResRequest (r->urlpath);