From: Francesco Chemolli Date: Thu, 19 Jul 2012 13:49:54 +0000 (+0200) Subject: Changed increment operators from postfix to prefix form. X-Git-Tag: sourceformat-review-1~164^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=14942eddc4ada4eea1bf57b9dcbe396545812258;p=thirdparty%2Fsquid.git Changed increment operators from postfix to prefix form. --- diff --git a/compat/xstring.cc b/compat/xstring.cc index 77db689ef0..ed31d92e73 100644 --- a/compat/xstring.cc +++ b/compat/xstring.cc @@ -39,8 +39,10 @@ xstrncpy(char *dst, const char *src, size_t n) return dst; if (src) - while (--n != 0 && *src != '\0') - *dst++ = *src++; + while (--n != 0 && *src != '\0') { + *dst++ = *src; + ++src; + } *dst = '\0'; return r; diff --git a/helpers/basic_auth/LDAP/basic_ldap_auth.cc b/helpers/basic_auth/LDAP/basic_ldap_auth.cc index 8e6f3c66f0..aef28f5834 100644 --- a/helpers/basic_auth/LDAP/basic_ldap_auth.cc +++ b/helpers/basic_auth/LDAP/basic_ldap_auth.cc @@ -623,13 +623,17 @@ ldap_escape_value(char *escaped, int size, const char *src) n += 3; size -= 3; if (size > 0) { - *escaped++ = '\\'; - snprintf(escaped, 3, "%02x", (unsigned char) *src++); + *escaped = '\\'; + ++escaped; + snprintf(escaped, 3, "%02x", (unsigned char) *src); + ++src; escaped += 2; } break; default: - *escaped++ = *src++; + *escaped = *src; + ++escaped; + ++src; ++n; --size; } diff --git a/helpers/basic_auth/RADIUS/basic_radius_auth.cc b/helpers/basic_auth/RADIUS/basic_radius_auth.cc index fe7432b29f..21c0fec96e 100644 --- a/helpers/basic_auth/RADIUS/basic_radius_auth.cc +++ b/helpers/basic_auth/RADIUS/basic_radius_auth.cc @@ -265,11 +265,15 @@ urldecode(char *dst, const char *src, int size) while (*src && size > 1) { if (*src == '%' && src[1] != '\0' && src[2] != '\0') { ++src; - tmp[0] = *src++; - tmp[1] = *src++; + tmp[0] = *src; + ++src; + tmp[1] = *src; + ++src; *dst++ = strtol(tmp, NULL, 16); } else { - *dst++ = *src++; + *dst = *src; + ++dst; + ++src; } --size; } diff --git a/helpers/basic_auth/RADIUS/radius-util.cc b/helpers/basic_auth/RADIUS/radius-util.cc index dd0ae70f44..af060c60a2 100644 --- a/helpers/basic_auth/RADIUS/radius-util.cc +++ b/helpers/basic_auth/RADIUS/radius-util.cc @@ -120,7 +120,9 @@ static uint32_t ipstr2long(char *ip_str) if (!isdigit(*ip_str)) { return((uint32_t)0); } - *ptr++ = *ip_str++; + *ptr = *ip_str; + ++ptr; + ++ip_str; ++count; } if (count >= 4 || count == 0) { diff --git a/helpers/digest_auth/LDAP/ldap_backend.cc b/helpers/digest_auth/LDAP/ldap_backend.cc index aed8467241..3b9bf670e2 100644 --- a/helpers/digest_auth/LDAP/ldap_backend.cc +++ b/helpers/digest_auth/LDAP/ldap_backend.cc @@ -171,12 +171,15 @@ ldap_escape_value(char *escaped, int size, const char *src) size -= 3; if (size > 0) { *escaped++ = '\\'; - snprintf(escaped, 3, "%02x", (int) *src++); + snprintf(escaped, 3, "%02x", (int) *src); + ++src; escaped += 2; } break; default: - *escaped++ = *src++; + *escaped = *src; + ++escaped; + ++src; ++n; --size; } diff --git a/helpers/digest_auth/eDirectory/ldap_backend.cc b/helpers/digest_auth/eDirectory/ldap_backend.cc index 1ed4622564..39dbe9eefa 100644 --- a/helpers/digest_auth/eDirectory/ldap_backend.cc +++ b/helpers/digest_auth/eDirectory/ldap_backend.cc @@ -172,12 +172,15 @@ ldap_escape_value(char *escaped, int size, const char *src) size -= 3; if (size > 0) { *escaped++ = '\\'; - snprintf(escaped, 3, "%02x", (int) *src++); + snprintf(escaped, 3, "%02x", (int) *src); + ++src; escaped += 2; } break; default: - *escaped++ = *src++; + *escaped = *src; + ++escaped; + ++src; ++n; --size; } diff --git a/helpers/external_acl/LDAP_group/ext_ldap_group_acl.cc b/helpers/external_acl/LDAP_group/ext_ldap_group_acl.cc index af03d8fcbc..314bc93f1e 100644 --- a/helpers/external_acl/LDAP_group/ext_ldap_group_acl.cc +++ b/helpers/external_acl/LDAP_group/ext_ldap_group_acl.cc @@ -632,12 +632,15 @@ ldap_escape_value(char *escaped, int size, const char *src) size -= 3; if (size > 0) { *escaped++ = '\\'; - snprintf(escaped, 3, "%02x", (unsigned char) *src++); + snprintf(escaped, 3, "%02x", (unsigned char) *src); + ++src; escaped += 2; } break; default: - *escaped++ = *src++; + *escaped = *src; + ++escaped; + ++src; ++n; --size; } diff --git a/src/WinSvc.cc b/src/WinSvc.cc index 5cfcbb6219..cfe0c4c6c2 100644 --- a/src/WinSvc.cc +++ b/src/WinSvc.cc @@ -160,7 +160,7 @@ WIN32_create_key(void) } hKey = hKeyNext; - index++; + ++index; } if (keys[index] == NULL) { @@ -268,7 +268,7 @@ static void WIN32_build_argv(char *cmd) /* Ignore spaces */ if (xisspace(*cmd)) { - cmd++; + ++cmd; continue; } @@ -276,7 +276,7 @@ static void WIN32_build_argv(char *cmd) word = cmd; while (*cmd) { - cmd++; /* Skip over this character */ + ++cmd; /* Skip over this character */ if (xisspace(*cmd)) /* End of argument if space */ break; @@ -602,7 +602,7 @@ void WIN32_svcstatusupdate(DWORD svcstate, DWORD WaitHint) { if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) { - svcStatus.dwCheckPoint++; + ++svcStatus.dwCheckPoint; svcStatus.dwWaitHint = WaitHint; svcStatus.dwCurrentState = svcstate; SetServiceStatus(svcHandle, &svcStatus); @@ -987,7 +987,7 @@ static int Win32SockInit(void) int optlen = sizeof(opt); if (s_iInitCount > 0) { - s_iInitCount++; + ++s_iInitCount; return (0); } else if (s_iInitCount < 0) return (s_iInitCount); @@ -1026,7 +1026,7 @@ static int Win32SockInit(void) } WIN32_Socks_initialized = 1; - s_iInitCount++; + ++s_iInitCount; return (s_iInitCount); } diff --git a/src/urn.cc b/src/urn.cc index 544e9498a4..bcff6ce78d 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -128,8 +128,8 @@ urnFindMinRtt(url_entry * urls, const HttpRequestMethod& m, int *rtt_ret) debugs(52, 3, "urnFindMinRtt"); assert(urls != NULL); - for (i = 0; NULL != urls[i].url; i++) - urlcnt++; + for (i = 0; NULL != urls[i].url; ++i) + ++urlcnt; debugs(53, 3, "urnFindMinRtt: Counted " << i << " URLs"); @@ -138,7 +138,7 @@ urnFindMinRtt(url_entry * urls, const HttpRequestMethod& m, int *rtt_ret) return urls; } - for (i = 0; i < urlcnt; i++) { + for (i = 0; i < urlcnt; ++i) { u = &urls[i]; debugs(52, 3, "urnFindMinRtt: " << u->host << " rtt=" << u->rtt); @@ -384,12 +384,12 @@ urnHandleReply(void *data, StoreIOBuffer result) delete rep; while (xisspace(*s)) - s++; + ++s; urls = urnParseReply(s, urnState->request->method); - for (i = 0; NULL != urls[i].url; i++) - urlcnt++; + for (i = 0; NULL != urls[i].url; ++i) + ++urlcnt; debugs(53, 3, "urnFindMinRtt: Counted " << i << " URLs"); @@ -412,7 +412,7 @@ urnHandleReply(void *data, StoreIOBuffer result) "

Select URL for %s

\n" "\n", e->url(), e->url()); - for (i = 0; i < urlcnt; i++) { + for (i = 0; i < urlcnt; ++i) { u = &urls[i]; debugs(52, 3, "URL {" << u->url << "}"); mb->Printf( @@ -449,7 +449,7 @@ urnHandleReply(void *data, StoreIOBuffer result) e->replaceHttpReply(rep); e->complete(); - for (i = 0; i < urlcnt; i++) { + for (i = 0; i < urlcnt; ++i) { safe_free(urls[i].url); safe_free(urls[i].host); } @@ -508,7 +508,7 @@ urnParseReply(const char *inbuf, const HttpRequestMethod& m) // TODO: Use storeHas() or lock/unlock entry to avoid creating unlocked // ones. list[i].flags.cached = storeGetPublic(url, m) ? 1 : 0; - i++; + ++i; } debugs(52, 3, "urnParseReply: Found " << i << " URLs"); diff --git a/src/wccp.cc b/src/wccp.cc index 2bcc5db0d4..013954d80c 100644 --- a/src/wccp.cc +++ b/src/wccp.cc @@ -283,7 +283,7 @@ wccpLowestIP(void) * We sanity checked wccp_i_see_you.number back in wccpHandleUdp() */ - for (loop = 0; loop < (unsigned) ntohl(wccp_i_see_you.number); loop++) { + for (loop = 0; loop < (unsigned) ntohl(wccp_i_see_you.number); ++loop) { assert(loop < WCCP_ACTIVE_CACHES); if (local_ip > wccp_i_see_you.wccp_cache_entry[loop].ip_addr) @@ -351,20 +351,22 @@ wccpAssignBuckets(void) buckets_per_cache = WCCP_BUCKETS / number_caches; - for (loop = 0; loop < number_caches; loop++) { + for (loop = 0; loop < number_caches; ++loop) { int i; memcpy(&caches[loop], &wccp_i_see_you.wccp_cache_entry[loop].ip_addr, sizeof(*caches)); - for (i = 0; i < buckets_per_cache; i++) { + for (i = 0; i < buckets_per_cache; ++i) { assert(bucket < WCCP_BUCKETS); - buckets[bucket++] = loop; + buckets[bucket] = loop; + ++bucket; } } while (bucket < WCCP_BUCKETS) { - buckets[bucket++] = number_caches - 1; + buckets[bucket] = number_caches - 1; + ++bucket; } wccp_assign_bucket->type = htonl(WCCP_ASSIGN_BUCKET); diff --git a/src/wccp2.cc b/src/wccp2.cc index 521fee239d..672f2b8ddd 100644 --- a/src/wccp2.cc +++ b/src/wccp2.cc @@ -701,7 +701,7 @@ wccp2Init(void) for (s = Config.Wccp2.router; s; s = s->next) { if (!s->s.IsAnyAddr()) { /* Increment the counter */ - wccp2_numrouters++; + ++wccp2_numrouters; } } @@ -1429,7 +1429,7 @@ wccp2HandleUdp(int sock, void *not_used) if (ntohl(tmp) != 0) { /* search through the list of received-from ip addresses */ - for (num_caches = 0; num_caches < (int) ntohl(tmp); num_caches++) { + for (num_caches = 0; num_caches < (int) ntohl(tmp); ++num_caches) { /* Get a copy of the ip */ memset(&cache_address, 0, sizeof(cache_address)); // Make GCC happy @@ -1798,7 +1798,7 @@ wccp2AssignBuckets(void *voidnotused) if (num_caches) { int cache; - for (cache = 0, cache_list_ptr = &router_list_ptr->cache_list_head; cache_list_ptr->next; cache_list_ptr = cache_list_ptr->next, cache++) { + for (cache = 0, cache_list_ptr = &router_list_ptr->cache_list_head; cache_list_ptr->next; cache_list_ptr = cache_list_ptr->next, ++cache) { /* add caches */ cache_address = (struct in_addr *) &wccp_packet[offset]; @@ -1818,7 +1818,7 @@ wccp2AssignBuckets(void *voidnotused) if (num_caches != 0) { if (total_weight == 0) { - for (bucket_counter = 0; bucket_counter < WCCP_BUCKETS; bucket_counter++) { + for (bucket_counter = 0; bucket_counter < WCCP_BUCKETS; ++bucket_counter) { buckets[bucket_counter] = (char) (bucket_counter % num_caches); } } else { @@ -1827,18 +1827,18 @@ wccp2AssignBuckets(void *voidnotused) int cache = -1; unsigned long per_bucket = total_weight / WCCP_BUCKETS; - for (bucket_counter = 0; bucket_counter < WCCP_BUCKETS; bucket_counter++) { + for (bucket_counter = 0; bucket_counter < WCCP_BUCKETS; ++bucket_counter) { int n; unsigned long step; for (n = num_caches; n; n--) { - cache++; + ++cache; if (cache >= num_caches) cache = 0; if (!weight[cache]) { - n++; + ++n; continue; } @@ -1899,13 +1899,13 @@ wccp2AssignBuckets(void *voidnotused) cache_list_ptr = &router_list_ptr->cache_list_head; value = 0; - for (valuecounter = 0; valuecounter < 64; valuecounter++) { + for (valuecounter = 0; valuecounter < 64; ++valuecounter) { value_element = (struct wccp2_value_element_t *) &wccp_packet[offset]; /* Update the value according the the "correct" formula */ - for (; (value & 0x1741) != value; value++) { + for (; (value & 0x1741) != value; ++value) { assert(value <= 0x1741); } @@ -1936,7 +1936,7 @@ wccp2AssignBuckets(void *voidnotused) value_element->cache_ip = cache_list_ptr->cache_ip; offset += sizeof(struct wccp2_value_element_t); - value++; + ++value; /* Assign the next value to the next cache */ @@ -2272,7 +2272,7 @@ parse_wccp2_service_ports(char *options, int portlist[]) } portlist[i] = p; - i++; + ++i; port = strsep(&tmp2, ","); } diff --git a/src/win32.cc b/src/win32.cc index 64776a5f52..69136407fe 100644 --- a/src/win32.cc +++ b/src/win32.cc @@ -70,7 +70,7 @@ int WIN32_pipe(int handles[2]) handles[0] = handles[1] = -1; - statCounter.syscalls.sock.sockets++; + ++statCounter.syscalls.sock.sockets; handle0 = localhost; handle0.SetPort(0); diff --git a/test-suite/splay.cc b/test-suite/splay.cc index 6f0a147fcd..0d0888eb9e 100644 --- a/test-suite/splay.cc +++ b/test-suite/splay.cc @@ -142,7 +142,7 @@ main(int argc, char *argv[]) splayNode *top = NULL; squid_srandom(time(NULL)); - for (i = 0; i < 100; i++) { + for (i = 0; i < 100; ++i) { I = (intnode *)xcalloc(sizeof(intnode), 1); I->i = squid_random(); top = top->insert(I, compareintvoid); @@ -164,7 +164,7 @@ main(int argc, char *argv[]) /* intnode* */ SplayNode *safeTop = NULL; - for ( int i = 0; i < 100; i++) { + for ( int i = 0; i < 100; ++i) { intnode *I; I = new intnode; I->i = squid_random(); @@ -183,7 +183,7 @@ main(int argc, char *argv[]) /* intnode */ SplayNode *safeTop = NULL; - for (int i = 0; i < 100; i++) { + for (int i = 0; i < 100; ++i) { intnode I; I.i = squid_random(); safeTop = safeTop->insert(I, compareintref); @@ -219,7 +219,7 @@ main(int argc, char *argv[]) if (safeTop->finish() != NULL) exit (1); - for (int i = 0; i < 100; i++) { + for (int i = 0; i < 100; ++i) { intnode I; I.i = squid_random(); diff --git a/tools/cachemgr.cc b/tools/cachemgr.cc index 0aabb5bbc4..bcb72f8552 100644 --- a/tools/cachemgr.cc +++ b/tools/cachemgr.cc @@ -175,7 +175,7 @@ int Win32SockInit(void) int err; if (s_iInitCount > 0) { - s_iInitCount++; + ++s_iInitCount; return (0); } else if (s_iInitCount < 0) return (s_iInitCount); @@ -197,7 +197,7 @@ int Win32SockInit(void) return (s_iInitCount); } - s_iInitCount++; + ++s_iInitCount; return (s_iInitCount); } @@ -245,7 +245,7 @@ xstrtok(char **str, char del) tok[--len] = '\0'; while (xisspace(*tok)) - tok++; + ++tok; return tok; } else @@ -352,7 +352,7 @@ auth_html(const char *host, int port, const char *user_name) if (comment) while (*comment == ' ' || *comment == '\t') - comment++; + ++comment; if (!comment || !*comment) comment = server; @@ -361,7 +361,7 @@ auth_html(const char *host, int port, const char *user_name) printf("\n"); next_is_header = is_header && strstr(buf, "\t\t"); - table_line_num++; + ++table_line_num; return html; } @@ -934,14 +934,14 @@ main(int argc, char *argv[]) value = args[1] + 2; } else if (argc > 2) { value = args[2]; - args++; + ++args; argc--; } else value = ""; #endif break; } - args++; + ++args; argc--; } @@ -1027,7 +1027,8 @@ read_request(void) if ((q = strchr(t, '=')) == NULL) continue; - *q++ = '\0'; + *q = '\0'; + ++q; rfc1738_unescape(t); diff --git a/tools/purge/conffile.cc b/tools/purge/conffile.cc index 177051ca23..ba48d44a96 100644 --- a/tools/purge/conffile.cc +++ b/tools/purge/conffile.cc @@ -136,7 +136,7 @@ readConfigFile( CacheDirVector& cachedir, const char* fn, FILE* debug ) cd.type = CacheDir::CDT_DISKD; else cd.type = CacheDir::CDT_OTHER; - offset++; + ++offset; } // extract base directory @@ -146,7 +146,7 @@ readConfigFile( CacheDirVector& cachedir, const char* fn, FILE* debug ) (int)subs[offset].rm_eo, line+subs[offset].rm_so ); cd.base = strdup( line+subs[offset].rm_so ); - offset++; + ++offset; // extract size information line[ subs[offset].rm_eo ] = '\0'; @@ -155,7 +155,7 @@ readConfigFile( CacheDirVector& cachedir, const char* fn, FILE* debug ) (int)subs[offset].rm_eo, line+subs[offset].rm_so ); cd.size = strtoul( line+subs[offset].rm_so, 0, 10 ); - offset++; + ++offset; // extract 1st level directories line[ subs[offset].rm_eo ] = '\0'; @@ -164,7 +164,7 @@ readConfigFile( CacheDirVector& cachedir, const char* fn, FILE* debug ) (int)subs[offset].rm_eo, line+subs[offset].rm_so ); cd.level[0] = strtoul( line+subs[offset].rm_so, 0, 10 ); - offset++; + ++offset; // extract 2nd level directories line[ subs[offset].rm_eo ] = '\0'; @@ -173,7 +173,7 @@ readConfigFile( CacheDirVector& cachedir, const char* fn, FILE* debug ) (int)subs[offset].rm_eo, line+subs[offset].rm_so ); cd.level[1] = strtoul( line+subs[offset].rm_so, 0, 10 ); - offset++; + ++offset; cachedir.push_back( cd ); } diff --git a/tools/purge/copyout.cc b/tools/purge/copyout.cc index c7db508cdb..fbd659a70e 100644 --- a/tools/purge/copyout.cc +++ b/tools/purge/copyout.cc @@ -157,7 +157,8 @@ copy_out( size_t filesize, size_t metasize, unsigned debug, } else if ( debug & 0x02 ) { fprintf( stderr, "# creating %s\n", filename ); } - *t++ = '/'; + *t = '/'; + ++t; } // create file diff --git a/tools/purge/purge.cc b/tools/purge/purge.cc index cae778c033..a23b07bdf2 100644 --- a/tools/purge/purge.cc +++ b/tools/purge/purge.cc @@ -246,7 +246,8 @@ isxstring( const char* s, size_t testlen ) if ( strlen(s) != testlen ) return false; size_t i=0; - while ( i= LINESIZE ) { fprintf( stderr, "%s:%lu: line too long, sorry.\n", @@ -712,7 +715,8 @@ parseCommandline( int argc, char* argv[], REList*& head, } } else { // colon used, port is extra - *colon++ = 0; + *colon = 0; + ++colon; if ( convertHostname(optarg,serverHost) == -1 ) { fprintf( stderr, "unable to resolve host %s!\n", optarg ); exit(1); @@ -779,7 +783,8 @@ parseCommandline( int argc, char* argv[], REList*& head, unsigned count(0); for ( tail = head; tail != NULL; tail = tail->next ) { - if ( count++ ) printf( "#%22u", count ); + if ( count++ ) + printf( "#%22u", count ); #if defined(LINUX) && putc==_IO_putc // I HATE BROKEN LINUX HEADERS! // purge.o(.text+0x1040): undefined reference to `_IO_putc'
Cache Server: