From: Francesco Chemolli Date: Mon, 2 Jul 2012 12:28:10 +0000 (+0200) Subject: Change increment and decrement operators from postfix to prefix form. X-Git-Tag: sourceformat-review-1~200 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=742a021bbcbb93c62f91d467ba4d6eabe33fe583;p=thirdparty%2Fsquid.git Change increment and decrement operators from postfix to prefix form. --- diff --git a/lib/MemPool.cc b/lib/MemPool.cc index 5b7b354166..86b97e7aaa 100644 --- a/lib/MemPool.cc +++ b/lib/MemPool.cc @@ -302,7 +302,7 @@ memPoolGetGlobalStats(MemPoolGlobalStats * stats) iter = memPoolIterate(); while ((pool = memPoolIterateNext(iter))) { if (pool->getStats(&pp_stats, 1) > 0) - pools_inuse++; + ++pools_inuse; } memPoolIterateDone(&iter); diff --git a/lib/MemPoolChunked.cc b/lib/MemPoolChunked.cc index 8068513a7f..a8245a4512 100644 --- a/lib/MemPoolChunked.cc +++ b/lib/MemPoolChunked.cc @@ -147,7 +147,7 @@ MemChunk::MemChunk(MemPoolChunked *aPool) freeList = objCache; void **Free = (void **)freeList; - for (int i = 1; i < pool->chunk_capacity; i++) { + for (int i = 1; i < pool->chunk_capacity; ++i) { *Free = (void *) ((char *) Free + pool->obj_size); void **nextFree = (void **)*Free; (void) VALGRIND_MAKE_MEM_NOACCESS(Free, pool->obj_size); @@ -158,7 +158,7 @@ MemChunk::MemChunk(MemPoolChunked *aPool) memMeterAdd(pool->getMeter().alloc, pool->chunk_capacity); memMeterAdd(pool->getMeter().idle, pool->chunk_capacity); - pool->chunkCount++; + ++pool->chunkCount; lastref = squid_curtime; pool->allChunks.insert(this, memCompChunks); } @@ -217,7 +217,7 @@ MemPoolChunked::get() { void **Free; - saved_calls++; + ++saved_calls; /* first, try cache */ if (freeCache) { @@ -239,7 +239,7 @@ MemPoolChunked::get() Free = (void **)chunk->freeList; chunk->freeList = *Free; *Free = NULL; - chunk->inuse_count++; + ++chunk->inuse_count; chunk->lastref = squid_curtime; if (chunk->freeList == NULL) { @@ -480,9 +480,9 @@ MemPoolChunked::getStats(MemPoolStats * stats, int accumulate) chunk = Chunks; while (chunk) { if (chunk->inuse_count == 0) - chunks_free++; + ++chunks_free; else if (chunk->inuse_count < chunk_capacity) - chunks_partial++; + ++chunks_partial; chunk = chunk->next; } diff --git a/lib/MemPoolMalloc.cc b/lib/MemPoolMalloc.cc index 8d9ead1b36..d6067cd9ac 100644 --- a/lib/MemPoolMalloc.cc +++ b/lib/MemPoolMalloc.cc @@ -57,7 +57,7 @@ MemPoolMalloc::allocate() void *obj = freelist.pop(); if (obj) { memMeterDec(meter.idle); - saved_calls++; + ++saved_calls; } else { obj = xcalloc(1, obj_size); memMeterInc(meter.alloc); diff --git a/lib/hash.cc b/lib/hash.cc index 08109ed22f..c3c8ce029a 100644 --- a/lib/hash.cc +++ b/lib/hash.cc @@ -71,7 +71,7 @@ hash_string(const void *data, unsigned int size) unsigned int j = 0; unsigned int i = 0; while (*s) { - j++; + ++j; n ^= 271 * (*s++); } i = n ^ (j * 271); @@ -169,7 +169,7 @@ hash_join(hash_table * hid, hash_link * lnk) i = hid->hash(lnk->key, hid->size); lnk->next = hid->buckets[i]; hid->buckets[i] = lnk; - hid->count++; + ++hid->count; } /** @@ -268,7 +268,7 @@ hash_remove_link(hash_table * hid, hash_link * hl) if (NULL == hid->next) hash_next_bucket(hid); } - hid->count--; + --hid->count; return; } assert(0); @@ -295,9 +295,9 @@ hashFreeItems(hash_table * hid, HASHFREE * free_func) hash_first(hid); while ((l = hash_next(hid)) && i < hid->count) { *(list + i) = l; - i++; + ++i; } - for (int j = 0; j < i; j++) + for (int j = 0; j < i; ++j) free_func(*(list + j)); xfree(list); } @@ -334,7 +334,7 @@ hashPrime(int n) int best_prime = hash_primes[0]; double min = fabs(log((double) n) - log((double) hash_primes[0])); double d; - for (int i = 0; i < I; i++) { + for (int i = 0; i < I; ++i) { d = fabs(log((double) n) - log((double) hash_primes[i])); if (d > min) continue; diff --git a/lib/malloc_trace.cc b/lib/malloc_trace.cc index ad5f8e8dc5..cc51817771 100644 --- a/lib/malloc_trace.cc +++ b/lib/malloc_trace.cc @@ -124,8 +124,8 @@ check_init(void) /* calloc the ptrs so that we don't see them when hunting lost memory */ malloc_ptrs = calloc(DBG_ARRY_BKTS, sizeof(*malloc_ptrs)); - for (B = 0; B < DBG_ARRY_BKTS; B++) { - for (I = 0; I < DBG_ARRY_SZ; I++) { + for (B = 0; B < DBG_ARRY_BKTS; ++B) { + for (I = 0; I < DBG_ARRY_SZ; ++I) { malloc_ptrs[B][I] = NULL; malloc_size[B][I] = 0; #if XMALLOC_TRACE @@ -147,7 +147,7 @@ check_free(void *s) int B, I; B = DBG_HASH_BUCKET(s); - for (I = 0; I < DBG_ARRY_SZ; I++) { + for (I = 0; I < DBG_ARRY_SZ; ++I) { if (malloc_ptrs[B][I] != s) continue; @@ -189,7 +189,7 @@ check_malloc(void *p, size_t sz) B = DBG_HASH_BUCKET(p); - for (I = 0; I < DBG_ARRY_SZ; I++) { + for (I = 0; I < DBG_ARRY_SZ; ++I) { if (!(P = malloc_ptrs[B][I])) continue; @@ -206,7 +206,7 @@ check_malloc(void *p, size_t sz) } } - for (I = 0; I < DBG_ARRY_SZ; I++) { + for (I = 0; I < DBG_ARRY_SZ; ++I) { if (malloc_ptrs[B][I]) continue; @@ -244,7 +244,7 @@ xmallocblksize(void *p) int B, I; B = DBG_HASH_BUCKET(p); - for (I = 0; I < DBG_ARRY_SZ; I++) { + for (I = 0; I < DBG_ARRY_SZ; ++I) { if (malloc_ptrs[B][I] == p) return malloc_size[B][I]; } @@ -261,7 +261,7 @@ malloc_file_name(void *p) int B, I; B = DBG_HASH_BUCKET(p); - for (I = 0; I < DBG_ARRY_SZ; I++) { + for (I = 0; I < DBG_ARRY_SZ; ++I) { if (malloc_ptrs[B][I] == p) return malloc_file[B][I]; } @@ -275,7 +275,7 @@ malloc_line_number(void *p) int B, I; B = DBG_HASH_BUCKET(p); - for (I = 0; I < DBG_ARRY_SZ; I++) { + for (I = 0; I < DBG_ARRY_SZ; ++I) { if (malloc_ptrs[B][I] == p) return malloc_line[B][I]; } @@ -289,7 +289,7 @@ malloc_number(void *p) int B, I; B = DBG_HASH_BUCKET(p); - for (I = 0; I < DBG_ARRY_SZ; I++) { + for (I = 0; I < DBG_ARRY_SZ; ++I) { if (malloc_ptrs[B][I] == p) return malloc_count[B][I]; } @@ -350,7 +350,7 @@ xmalloc_scan_region(void *start, int size, int depth) if (p && p != start) { B = DBG_HASH_BUCKET(p); - for (I = 0; I < DBG_ARRY_SZ; I++) { + for (I = 0; I < DBG_ARRY_SZ; ++I) { if (malloc_ptrs[B][I] == p) { if (!malloc_refs[B][I]++) { /* A new reference */ @@ -399,8 +399,8 @@ xmalloc_find_leaks(void) fprintf(stderr, "----- Memory map ----\n"); xmalloc_scan_region(&_etext, (void *) sbrk(0) - (void *) &_etext, 0); - for (B = 0; B < DBG_ARRY_BKTS; B++) { - for (I = 0; I < DBG_ARRY_SZ; I++) { + for (B = 0; B < DBG_ARRY_BKTS; ++B) { + for (I = 0; I < DBG_ARRY_SZ; ++I) { if (malloc_ptrs[B][I] && malloc_refs[B][I] == 0) { /* Found a leak... */ fprintf(stderr, "Leak found: %p", malloc_ptrs[B][I]); diff --git a/lib/ntlmauth/ntlmauth.cc b/lib/ntlmauth/ntlmauth.cc index 5a71feebf1..def632c14a 100644 --- a/lib/ntlmauth/ntlmauth.cc +++ b/lib/ntlmauth/ntlmauth.cc @@ -137,25 +137,25 @@ ntlm_fetch_string(const ntlmhdr *packet, const int32_t packet_size, const strhdr unsigned short *s = (unsigned short *)rv.str; rv.str = d = buf; - for (l >>= 1; l; s++, l--) { + for (l >>= 1; l; ++s, --l) { unsigned short c = le16toh(*s); if (c > 254 || c == '\0') { fprintf(stderr, "ntlmssp: bad unicode: %04x\n", c); return rv; } *d++ = c; - rv.l++; + ++rv.l; } } else { /* ASCII/OEM string */ char *sc = rv.str; - for (; l>=0; sc++, l--) { + for (; l>=0; ++sc, --l) { if (*sc == '\0' || !xisprint(*sc)) { fprintf(stderr, "ntlmssp: bad ascii: %04x\n", *sc); return rv; } - rv.l++; + ++rv.l; } } @@ -209,7 +209,7 @@ ntlm_make_nonce(char *nonce) int r = (int) rand(); r = (hash ^ r) + r; - for (i = 0; i < NTLM_NONCE_LEN; i++) { + for (i = 0; i < NTLM_NONCE_LEN; ++i) { nonce[i] = r; r = (r >> 2) ^ r; } diff --git a/lib/profiler/Profiler.cc b/lib/profiler/Profiler.cc index a608ae888e..7a6ec7ca1b 100644 --- a/lib/profiler/Profiler.cc +++ b/lib/profiler/Profiler.cc @@ -161,7 +161,7 @@ xprof_update(xprof_stats_data * head) if (head->worst < head->delta) head->worst = head->delta; head->summ += head->delta; - head->count++; + ++head->count; } static xprof_stats_data *xp_UNACCOUNTED; @@ -209,7 +209,7 @@ xprof_start(xprof_type type, const char *timer) cstack[cstack_head].accum = 0; cstack[cstack_head].timer = type; cstack[cstack_head].name = timer; - cstack_head++; + ++cstack_head; assert(cstack_head < MAXSTACKDEPTH); } @@ -219,7 +219,7 @@ xprof_stop(xprof_type type, const char *timer) { hrtime_t tt = get_tick(); assert(cstack_head > 0); - cstack_head--; + --cstack_head; assert(cstack[cstack_head].timer == type); /* Record timer details */ diff --git a/src/acl/Asn.cc b/src/acl/Asn.cc index bf54622dbe..b584eb57ba 100644 --- a/src/acl/Asn.cc +++ b/src/acl/Asn.cc @@ -201,12 +201,14 @@ CBDATA_TYPE(ASState); void asnInit(void) { - static int inited = 0; + static bool inited = false; squid_max_keylen = 40; CBDATA_INIT_TYPE(ASState); - if (0 == inited++) + if (!inited) { + inited = true; squid_rn_init(); + } squid_rn_inithead(&AS_tree_head, 8); @@ -310,9 +312,9 @@ asHandleReply(void *data, StoreIOBuffer result) while ((size_t)(s - buf) < result.length + asState->reqofs && *s != '\0') { while (*s && xisspace(*s)) - s++; + ++s; - for (t = s; *t; t++) { + for (t = s; *t; ++t) { if (xisspace(*t)) break; } @@ -635,7 +637,7 @@ ACLDestinationASNStrategy::match (ACLData * &data, ACLFilledChecklist const ipcache_addrs *ia = ipcache_gethostbyname(checklist->request->GetHost(), IP_LOOKUP_IF_MISS); if (ia) { - for (int k = 0; k < (int) ia->count; k++) { + for (int k = 0; k < (int) ia->count; ++k) { if (data->match(ia->in_addrs[k])) return 1; } diff --git a/src/acl/DestinationIp.cc b/src/acl/DestinationIp.cc index 3255650678..287d397f29 100644 --- a/src/acl/DestinationIp.cc +++ b/src/acl/DestinationIp.cc @@ -67,7 +67,7 @@ ACLDestinationIP::match(ACLChecklist *cl) if (ia) { /* Entry in cache found */ - for (int k = 0; k < (int) ia->count; k++) { + for (int k = 0; k < (int) ia->count; ++k) { if (ACLIP::match(ia->in_addrs[k])) return 1; } diff --git a/src/acl/Gadgets.cc b/src/acl/Gadgets.cc index 90c5eec138..42ad7569de 100644 --- a/src/acl/Gadgets.cc +++ b/src/acl/Gadgets.cc @@ -214,7 +214,7 @@ aclParseAclList(ConfigParser &parser, ACLList ** head) if (*t == '!') { L->negated (true); - t++; + ++t; } debugs(28, 3, "aclParseAclList: looking for ACL name '" << t << "'"); diff --git a/src/acl/Ip.cc b/src/acl/Ip.cc index b1c05c360c..a91d464a65 100644 --- a/src/acl/Ip.cc +++ b/src/acl/Ip.cc @@ -99,7 +99,7 @@ acl_ip_data::toStr(char *buf, int len) const if (!addr2.IsAnyAddr()) { b2[0] = '-'; - rlen++; + ++rlen; addr2.NtoA(&(b2[1]), len - rlen ); rlen = strlen(buf); } else @@ -109,7 +109,7 @@ acl_ip_data::toStr(char *buf, int len) const if (!mask.IsNoAddr()) { b3[0] = '/'; - rlen++; + ++rlen; int cidr = mask.GetCIDR() - (addr1.IsIPv4()?96:0); snprintf(&(b3[1]), (len-rlen), "%u", (unsigned int)(cidr<0?0:cidr) ); } else diff --git a/src/acl/RegexData.cc b/src/acl/RegexData.cc index 2138e46c4d..34b99fb14e 100644 --- a/src/acl/RegexData.cc +++ b/src/acl/RegexData.cc @@ -238,11 +238,11 @@ compileOptimisedREs(relist **curlist, wordlist * wl) if (largeREindex > 0) largeRE[largeREindex++] = '|'; largeRE[largeREindex++] = '('; - for (char * t = wl->key; *t != '\0'; t++) + for (char * t = wl->key; *t != '\0'; ++t) largeRE[largeREindex++] = *t; largeRE[largeREindex++] = ')'; largeRE[largeREindex] = '\0'; - numREs++; + ++numREs; } else { debugs(28, 2, "compileOptimisedREs: buffer full, generating new optimised RE..." ); newlistp = compileRE( newlistp, largeRE, flags ); diff --git a/src/adaptation/Config.cc b/src/adaptation/Config.cc index 17a1d79ef9..e19e81a67a 100644 --- a/src/adaptation/Config.cc +++ b/src/adaptation/Config.cc @@ -226,7 +226,7 @@ Adaptation::Config::finalize() ServicePointer s = createService(cfg); if (s != NULL) { AllServices().push_back(s); - created++; + ++created; } } @@ -285,7 +285,7 @@ Adaptation::Config::ParseMetaHeader(ConfigParser &parser) ConfigParser::ParseQuotedString(&value); // TODO: Find a way to move this check to ICAP - for (int i = 0; warnFor[i] != NULL; i++) { + for (int i = 0; warnFor[i] != NULL; ++i) { if (name.caseCmp(warnFor[i]) == 0) { fatalf("%s:%d: meta name \"%s\" is a reserved ICAP header name", cfg_filename, config_lineno, name.termedBuf()); diff --git a/src/adaptation/ServiceConfig.cc b/src/adaptation/ServiceConfig.cc index ecffe2e19a..48d43a7857 100644 --- a/src/adaptation/ServiceConfig.cc +++ b/src/adaptation/ServiceConfig.cc @@ -187,7 +187,7 @@ Adaptation::ServiceConfig::grokUri(const char *value) if ((t = strchr(s, ']')) == NULL) return false; - s++; + ++s; len = t - s; if ((e = strchr(t, ':')) != NULL) { have_port = true; @@ -212,7 +212,7 @@ Adaptation::ServiceConfig::grokUri(const char *value) port = -1; if (have_port) { - s++; + ++s; if ((e = strchr(s, '/')) != NULL) { char *t; @@ -235,7 +235,7 @@ Adaptation::ServiceConfig::grokUri(const char *value) // if no port, the caller may use service_configConfigs or supply the default if neeeded - s++; + ++s; e = strchr(s, '\0'); len = e - s; diff --git a/src/adaptation/icap/ServiceRep.cc b/src/adaptation/icap/ServiceRep.cc index 25823921dc..298143d2fb 100644 --- a/src/adaptation/icap/ServiceRep.cc +++ b/src/adaptation/icap/ServiceRep.cc @@ -479,7 +479,7 @@ void Adaptation::Icap::ServiceRep::checkOptions() method_list.append(ICAP::methodStr(*iter)); method_list.append(" ", 1); - iter++; + ++iter; } if (!method_found) { diff --git a/src/auth/User.cc b/src/auth/User.cc index a86a866f1f..960fe56660 100644 --- a/src/auth/User.cc +++ b/src/auth/User.cc @@ -140,10 +140,10 @@ Auth::User::absorb(Auth::User::Pointer from) if (!found) { /* This ip is not in the seen list. Add it. */ dlinkAddTail(&new_ipdata->node, &ipdata->node, &ip_list); - ipcount++; + ++ipcount; /* remove from the source list */ dlinkDelete(&new_ipdata->node, &(from->ip_list)); - from->ipcount--; + ++from->ipcount; } } } @@ -334,7 +334,7 @@ Auth::User::addIp(Ip::Address ipaddr) dlinkAddTail(ipdata, &ipdata->node, &ip_list); - ipcount++; + ++ipcount; debugs(29, 2, HERE << "user '" << username() << "' has been seen at a new IP address (" << ipaddr << ")"); } diff --git a/src/auth/basic/auth_basic.cc b/src/auth/basic/auth_basic.cc index 00531121ec..cf506c55b8 100644 --- a/src/auth/basic/auth_basic.cc +++ b/src/auth/basic/auth_basic.cc @@ -223,11 +223,11 @@ Auth::Basic::Config::decodeCleartext(const char *httpAuthHeader) /* trim BASIC from string */ while (xisgraph(*proxy_auth)) - proxy_auth++; + ++proxy_auth; /* Trim leading whitespace before decoding */ while (xisspace(*proxy_auth)) - proxy_auth++; + ++proxy_auth; /* Trim trailing \n before decoding */ // XXX: really? is the \n actually still there? does the header parse not drop it? diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index 6765b65ac0..01895d9c95 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -186,7 +186,7 @@ authenticateDigestNonceNew(void) /* create a new nonce */ newnonce->noncedata.randomdata = squid_random(); /* Bug 3526 high performance fix: add 1 second to creationtime to avoid duplication */ - newnonce->noncedata.creationtime++; + ++newnonce->noncedata.creationtime; authDigestNonceEncode(newnonce); } @@ -298,7 +298,7 @@ static void authDigestNonceLink(digest_nonce_h * nonce) { assert(nonce != NULL); - nonce->references++; + ++nonce->references; debugs(29, 9, "authDigestNonceLink: nonce '" << nonce << "' now at '" << nonce->references << "'."); } @@ -379,7 +379,7 @@ authDigestNonceIsValid(digest_nonce_h * nonce, char nc[9]) /* is the nonce-count ok ? */ if (!static_cast(Auth::Config::Find("digest"))->CheckNonceCount) { - nonce->nc++; + ++nonce->nc; return -1; /* forced OK by configuration */ } @@ -796,11 +796,11 @@ Auth::Digest::Config::decode(char const *proxy_auth) /* trim DIGEST from string */ while (xisgraph(*proxy_auth)) - proxy_auth++; + ++proxy_auth; /* Trim leading whitespace before decoding */ while (xisspace(*proxy_auth)) - proxy_auth++; + ++proxy_auth; String temp(proxy_auth); diff --git a/src/auth/negotiate/UserRequest.cc b/src/auth/negotiate/UserRequest.cc index e0fa1964b9..f4e23897f6 100644 --- a/src/auth/negotiate/UserRequest.cc +++ b/src/auth/negotiate/UserRequest.cc @@ -179,13 +179,13 @@ Auth::Negotiate::UserRequest::authenticate(HttpRequest * aRequest, ConnStateData if (blob) { while (xisspace(*blob) && *blob) - blob++; + ++blob; while (!xisspace(*blob) && *blob) - blob++; + ++blob; while (xisspace(*blob) && *blob) - blob++; + ++blob; } switch (user()->credentials()) { diff --git a/src/auth/ntlm/UserRequest.cc b/src/auth/ntlm/UserRequest.cc index efdb33d255..9fbf7b8e6b 100644 --- a/src/auth/ntlm/UserRequest.cc +++ b/src/auth/ntlm/UserRequest.cc @@ -173,13 +173,13 @@ Auth::Ntlm::UserRequest::authenticate(HttpRequest * aRequest, ConnStateData * co /* if proxy_auth is actually NULL, we'd better not manipulate it. */ if (blob) { while (xisspace(*blob) && *blob) - blob++; + ++blob; while (!xisspace(*blob) && *blob) - blob++; + ++blob; while (xisspace(*blob) && *blob) - blob++; + ++blob; } switch (user()->credentials()) { @@ -262,7 +262,7 @@ Auth::Ntlm::UserRequest::HandleReply(void *data, void *lastserver, char *reply) /* seperate out the useful data */ blob = strchr(reply, ' '); if (blob) - blob++; + ++blob; if (strncasecmp(reply, "TT ", 3) == 0) { /* we have been given a blob to send to the client */ diff --git a/src/base/TextException.cc b/src/base/TextException.cc index 30aab6c4bb..60fd7304e8 100644 --- a/src/base/TextException.cc +++ b/src/base/TextException.cc @@ -51,12 +51,12 @@ unsigned int TextException::FileNameHash(const char *fname) s = strrchr(fname, '/'); if (s) - s++; + ++s; else s = fname; while (*s) { - j++; + ++j; n ^= 271 * (unsigned) *s++; } i = n ^ (j * 271); diff --git a/src/snmp_core.cc b/src/snmp_core.cc index 9d6cdc0405..5b17dd290e 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -765,7 +765,7 @@ peer_Inst(oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn) int no = name[current->len] ; int i; // Note: This works because the Config.peers keeps its index according to its position. - for ( i=0 ; peers && (i < no) ; peers = peers->next , i++ ) ; + for ( i=0 ; peers && (i < no) ; peers = peers->next , ++i ) ; if (peers) { debugs(49, 6, "snmp peer_Inst: Encode peer #" << i);