From: Francesco Chemolli Date: Fri, 25 Jan 2013 16:53:16 +0000 (+0100) Subject: Refactor type of some flags to bool X-Git-Tag: SQUID_3_4_0_1~346 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3dd52a0bce52e3f4654e38cd13891b74d5aa6309;p=thirdparty%2Fsquid.git Refactor type of some flags to bool Affected classes: StoreClient, mem_node, AclUserData, AclMaxUserIp, Auth::Digest::UserRequest, digest_nonce_h --- diff --git a/src/StoreClient.h b/src/StoreClient.h index e6f1001f50..9264c6fd74 100644 --- a/src/StoreClient.h +++ b/src/StoreClient.h @@ -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 diff --git a/src/acl/UserData.cc b/src/acl/UserData.cc index 0579f5aff0..e023f3b113 100644 --- a/src/acl/UserData.cc +++ b/src/acl/UserData.cc @@ -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); diff --git a/src/acl/UserData.h b/src/acl/UserData.h index e5d0d4d70c..39e6374907 100644 --- a/src/acl/UserData.h +++ b/src/acl/UserData.h @@ -53,8 +53,8 @@ public: SplayNode *names; struct { - unsigned int case_insensitive:1; - unsigned int required:1; + bool case_insensitive; + bool required; } flags; }; diff --git a/src/auth/AclMaxUserIp.cc b/src/auth/AclMaxUserIp.cc index ddb6b054a9..e297ddad12 100644 --- a/src/auth/AclMaxUserIp.cc +++ b/src/auth/AclMaxUserIp.cc @@ -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(); } diff --git a/src/auth/AclMaxUserIp.h b/src/auth/AclMaxUserIp.h index 82913e2510..5d5e962b1c 100644 --- a/src/auth/AclMaxUserIp.h +++ b/src/auth/AclMaxUserIp.h @@ -73,9 +73,9 @@ private: int maximum; struct Flags { - Flags() : strict(0) {} + Flags() : strict(false) {} - unsigned int strict:1; + bool strict; } flags; }; diff --git a/src/auth/digest/UserRequest.cc b/src/auth/digest/UserRequest.cc index fbbb43069e..f1059aa05a 100644 --- a/src/auth/digest/UserRequest.cc +++ b/src/auth/digest/UserRequest.cc @@ -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::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) { diff --git a/src/auth/digest/UserRequest.h b/src/auth/digest/UserRequest.h index 011be30dab..6c328ed933 100644 --- a/src/auth/digest/UserRequest.h +++ b/src/auth/digest/UserRequest.h @@ -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; diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index 112b3d4904..7f47df99b1 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -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::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::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::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); diff --git a/src/auth/digest/auth_digest.h b/src/auth/digest/auth_digest.h index fc24aba0e8..1b3892d618 100644 --- a/src/auth/digest/auth_digest.h +++ b/src/auth/digest/auth_digest.h @@ -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; }; diff --git a/src/mem_node.cc b/src/mem_node.cc index dc59c3049f..d79aa2129b 100644 --- a/src/mem_node.cc +++ b/src/mem_node.cc @@ -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; } diff --git a/src/mem_node.h b/src/mem_node.h index a01765ec2b..214028caee 100644 --- a/src/mem_node.h +++ b/src/mem_node.h @@ -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); diff --git a/src/stmem.cc b/src/stmem.cc index 1465a9fbe7..c00aa436ba 100644 --- a/src/stmem.cc +++ b/src/stmem.cc @@ -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; } diff --git a/src/store_client.cc b/src/store_client.cc index 15c1e9462c..56ce3c6d45 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -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); diff --git a/src/urn.cc b/src/urn.cc index e9967443b6..cf4ce339f3 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -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);