From: Francesco Chemolli Date: Mon, 23 Jul 2012 15:34:12 +0000 (+0200) Subject: Changed increment operators from postfix to prefix form. X-Git-Tag: sourceformat-review-1~164^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a38ec4b1162f628a88c6b2da95a75b07e51a8414;p=thirdparty%2Fsquid.git Changed increment operators from postfix to prefix form. --- diff --git a/src/HttpHdrCc.cc b/src/HttpHdrCc.cc index 4d86e7e461..4b77ebec27 100644 --- a/src/HttpHdrCc.cc +++ b/src/HttpHdrCc.cc @@ -121,10 +121,12 @@ HttpHdrCc::parse(const String & str) while (strListGetItem(&str, ',', &item, &ilen, &pos)) { /* isolate directive name */ - if ((p = (const char *)memchr(item, '=', ilen)) && (p - item < ilen)) - nlen = p++ - item; - else + if ((p = (const char *)memchr(item, '=', ilen)) && (p - item < ilen)) { + nlen = p - item; + ++p; + } else { nlen = ilen; + } /* find type */ const CcNameToIdMap_t::const_iterator i=CcNameToIdMap.find(StringArea(item,nlen)); diff --git a/src/HttpHdrSc.cc b/src/HttpHdrSc.cc index fdd5a4a37d..34e94f3bb3 100644 --- a/src/HttpHdrSc.cc +++ b/src/HttpHdrSc.cc @@ -140,8 +140,10 @@ HttpHdrSc::parse(const String * str) } /* decrease ilen to still match the token for ';' qualified non '=' statments */ - else if ((p = strchr(item, ';')) && (p - item < ilen)) - ilen = p++ - item; + else if ((p = strchr(item, ';')) && (p - item < ilen)) { + ilen = p - item; + ++p; + } /* find type */ /* TODO: use a type-safe map-based lookup */ diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index edeb9c640d..4e8a8228e5 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -596,8 +596,10 @@ HttpHeader::parse(const char *header_start, const char *header_end) if (Config.onoff.relaxed_header_parser) { char *p = (char *) this_line; /* XXX Warning! This destroys original header content and violates specifications somewhat */ - while ((p = (char *)memchr(p, '\r', field_end - p)) != NULL) - *p++ = ' '; + while ((p = (char *)memchr(p, '\r', field_end - p)) != NULL) { + *p = ' '; + ++p; + } } else goto reset; } diff --git a/src/cache_cf.cc b/src/cache_cf.cc index e46ba0e60c..2360ec5353 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -247,7 +247,7 @@ update_maxobjsize(void) int i; int64_t ms = -1; - for (i = 0; i < Config.cacheSwap.n_configured; i++) { + for (i = 0; i < Config.cacheSwap.n_configured; ++i) { assert (Config.cacheSwap.swapDirs[i].getRaw()); if (dynamic_cast(Config.cacheSwap.swapDirs[i].getRaw())-> @@ -295,7 +295,7 @@ parseManyConfigFiles(char* files, int depth) path, xstrerror()); } } - for (i = 0; i < (int)globbuf.gl_pathc; i++) { + for (i = 0; i < (int)globbuf.gl_pathc; ++i) { error_count += parseOneConfigFile(globbuf.gl_pathv[i], depth); } globfree(&globbuf); @@ -453,7 +453,7 @@ parseOneConfigFile(const char *file_name, unsigned int depth) Vector if_states; while (fgets(config_input_line, BUFSIZ, fp)) { - config_lineno++; + ++config_lineno; if ((token = strchr(config_input_line, '\n'))) *token = '\0'; @@ -477,7 +477,7 @@ parseOneConfigFile(const char *file_name, unsigned int depth) continue; /* Not a valid #line directive, may be a comment */ while (*file && xisspace((unsigned char) *file)) - file++; + ++file; if (*file) { if (*file != '"') @@ -538,7 +538,7 @@ parseOneConfigFile(const char *file_name, unsigned int depth) err_count += parseManyConfigFiles(tmp_line + 8, depth + 1); } else if (!parse_line(tmp_line)) { debugs(3, 0, HERE << cfg_filename << ":" << config_lineno << " unrecognized: '" << tmp_line << "'"); - err_count++; + ++err_count; } } @@ -1188,7 +1188,7 @@ static void parseBytesOptionValue(size_t * bptr, const char *units, char const * char const * number_end = value; while ((*number_end >= '0' && *number_end <= '9')) { - number_end++; + ++number_end; } String number; @@ -1757,7 +1757,7 @@ dump_cachedir(StoreEntry * entry, const char *name, SquidConfig::_cacheSwap swap int i; assert (entry); - for (i = 0; i < swap.n_configured; i++) { + for (i = 0; i < swap.n_configured; ++i) { s = dynamic_cast(swap.swapDirs[i].getRaw()); if (!s) continue; storeAppendPrintf(entry, "%s %s %s", name, s->type(), s->path); @@ -1866,7 +1866,7 @@ parse_cachedir(SquidConfig::_cacheSwap * swap) /* reconfigure existing dir */ - for (i = 0; i < swap->n_configured; i++) { + for (i = 0; i < swap->n_configured; ++i) { assert (swap->swapDirs[i].getRaw()); if ((strcasecmp(path_str, dynamic_cast(swap->swapDirs[i].getRaw())->path)) == 0) { @@ -2129,8 +2129,10 @@ parse_peer(peer ** head) char *mode, *nextmode; for (mode = nextmode = tmp; mode; mode = nextmode) { nextmode = strchr(mode, ','); - if (nextmode) - *nextmode++ = '\0'; + if (nextmode) { + *nextmode = '\0'; + ++nextmode; + } if (!strcasecmp(mode, "no-clr")) { if (p->options.htcp_only_clr) fatalf("parse_peer: can't set htcp-no-clr and htcp-only-clr simultaneously"); @@ -2497,7 +2499,7 @@ parse_hostdomain(void) if (*domain == '!') { /* check for !.edu */ l->do_ping = 0; - domain++; + ++domain; } l->domain = xstrdup(domain); @@ -2939,7 +2941,7 @@ parse_eol(char *volatile *var) } while (*token && xisspace(*token)) - token++; + ++token; if (!*token) { self_destruct(); @@ -3451,7 +3453,8 @@ parsePortSpecification(AnyP::PortCfg * s, char *token) debugs(3, DBG_CRITICAL, s->protocol << "_port: missing ']' on IPv6 address: " << token); self_destruct(); } - *t++ = '\0'; + *t = '\0'; + ++t; if (*t != ':') { debugs(3, DBG_CRITICAL, s->protocol << "_port: missing Port in: " << token); self_destruct(); @@ -3637,12 +3640,12 @@ parse_port_option(AnyP::PortCfg * s, char *token) s->tcp_keepalive.idle = atoi(t); t = strchr(t, ','); if (t) { - t++; + ++t; s->tcp_keepalive.interval = atoi(t); t = strchr(t, ','); } if (t) { - t++; + ++t; s->tcp_keepalive.timeout = atoi(t); t = strchr(t, ','); } @@ -4353,7 +4356,7 @@ static void parse_sslproxy_cert_adapt(sslproxy_cert_adapt **cert_adapt) const char *param; if ( char *s = strchr(al, '{')) { *s = '\0'; // terminate the al string - s++; + ++s; param = s; s = strchr(s, '}'); if (!s) { diff --git a/src/carp.cc b/src/carp.cc index d0554b5613..ae5a423d93 100644 --- a/src/carp.cc +++ b/src/carp.cc @@ -128,7 +128,8 @@ carpInit(void) p->carp.load_factor = 0.0; /* add it to our list of peers */ - *P++ = cbdataReference(p); + *P = cbdataReference(p); + ++P; } /* Sort our list on weight */ diff --git a/src/client_side.cc b/src/client_side.cc index 218943de84..946ffd7a5f 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1979,8 +1979,10 @@ setLogUri(ClientHttpRequest * http, char const *uri, bool cleanUrl) char *q = tmp_uri; t = uri; while (*t) { - if (!xisspace(*t)) - *q++ = *t; + if (!xisspace(*t)) { + *q = *t; + ++q; + } ++t; } *q = '\0'; @@ -4025,7 +4027,8 @@ clientHttpConnectionsOpen(void) ListeningStartedDialer(&clientListenerConnectionOpened, s, Ipc::fdnHttpSocket, sub)); Ipc::StartListening(SOCK_STREAM, IPPROTO_TCP, s->listenConn, Ipc::fdnHttpSocket, listenCall); - HttpSockets[NHttpSockets++] = -1; // set in clientListenerConnectionOpened + HttpSockets[NHttpSockets] = -1; // set in clientListenerConnectionOpened + ++NHttpSockets; } } @@ -4079,7 +4082,8 @@ clientHttpsConnectionsOpen(void) ListeningStartedDialer(&clientListenerConnectionOpened, s, Ipc::fdnHttpsSocket, sub)); Ipc::StartListening(SOCK_STREAM, IPPROTO_TCP, s->listenConn, Ipc::fdnHttpsSocket, listenCall); - HttpSockets[NHttpSockets++] = -1; + HttpSockets[NHttpSockets] = -1; + ++NHttpSockets; } } #endif diff --git a/src/errorpage.cc b/src/errorpage.cc index ae29c56f0b..a6efcdceb3 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -414,7 +414,8 @@ bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &p } ++pos; } - *dt++ = '\0'; // nul-terminated the filename content string before system use. + *dt = '\0'; // nul-terminated the filename content string before system use. + ++dt; debugs(4, 9, HERE << "STATE: dt='" << dt << "', lang='" << lang << "', pos=" << pos << ", buf='" << ((pos < hdr.size()) ? hdr.substr(pos,hdr.size()) : "") << "'"); diff --git a/src/external_acl.cc b/src/external_acl.cc index fdf15a27cf..c173798001 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -264,12 +264,15 @@ parse_header_token(external_acl_format *format, char *header, const _external_ac if (member) { /* Split in header and member */ - *member++ = '\0'; + *member = '\0'; + ++member; - if (!xisalnum(*member)) - format->separator = *member++; - else + if (!xisalnum(*member)) { + format->separator = *member; + ++member; + } else { format->separator = ','; + } format->member = xstrdup(member); @@ -1333,7 +1336,8 @@ externalAclHandleReply(void *data, char *reply) value = strchr(token, '='); if (value) { - *value++ = '\0'; /* terminate the token, and move up to the value */ + *value = '\0'; /* terminate the token, and move up to the value */ + ++value; if (state->def->quote == external_acl::QUOTE_METHOD_URL) rfc1738_unescape(value); diff --git a/src/format/Format.cc b/src/format/Format.cc index 12fa129110..bfd4f0455b 100644 --- a/src/format/Format.cc +++ b/src/format/Format.cc @@ -262,26 +262,34 @@ log_quoted_string(const char *str, char *out) break; case '\r': - *p++ = '\\'; - *p++ = 'r'; + *p = '\\'; + ++p; + *p = 'r'; + ++p; ++str; break; case '\n': - *p++ = '\\'; - *p++ = 'n'; + *p = '\\'; + ++p; + *p = 'n'; + ++p; ++str; break; case '\t': - *p++ = '\\'; - *p++ = 't'; + *p = '\\'; + ++p; + *p = 't'; + ++p; ++str; break; default: - *p++ = '\\'; - *p++ = *str; + *p = '\\'; + ++p; + *p = *str; + ++p; ++str; break; } diff --git a/src/format/Quoting.cc b/src/format/Quoting.cc index 6568941ecd..c27c7b0532 100644 --- a/src/format/Quoting.cc +++ b/src/format/Quoting.cc @@ -116,11 +116,15 @@ Format::QuoteMimeBlob(const char *header) while ((c = *(const unsigned char *) header++) != '\0') { #if !OLD_LOG_MIME if (c == '\r') { - *buf_cursor++ = '\\'; - *buf_cursor++ = 'r'; + *buf_cursor = '\\'; + ++buf_cursor; + *buf_cursor = 'r'; + ++buf_cursor; } else if (c == '\n') { - *buf_cursor++ = '\\'; - *buf_cursor++ = 'n'; + *buf_cursor = '\\'; + ++buf_cursor; + *buf_cursor = 'n'; + ++buf_cursor; } else #endif if (c <= 0x1F @@ -143,19 +147,25 @@ Format::QuoteMimeBlob(const char *header) #endif || c == '[' || c == ']') { - *buf_cursor++ = '%'; + *buf_cursor = '%'; + ++buf_cursor; i = c * 2; - *buf_cursor++ = c2x[i]; - *buf_cursor++ = c2x[i + 1]; + *buf_cursor = c2x[i]; + ++buf_cursor; + *buf_cursor = c2x[i + 1]; + ++buf_cursor; #if !OLD_LOG_MIME } else if (c == '\\') { - *buf_cursor++ = '\\'; - *buf_cursor++ = '\\'; + *buf_cursor = '\\'; + ++buf_cursor; + *buf_cursor = '\\'; + ++buf_cursor; #endif } else { - *buf_cursor++ = (char) c; + *buf_cursor = (char) c; + ++buf_cursor; } } diff --git a/src/format/Token.cc b/src/format/Token.cc index 087a526ee1..4922099bee 100644 --- a/src/format/Token.cc +++ b/src/format/Token.cc @@ -429,12 +429,15 @@ done: char *cp = strchr(header, ':'); if (cp) { - *cp++ = '\0'; + *cp = '\0'; + ++cp; - if (*cp == ',' || *cp == ';' || *cp == ':') - data.header.separator = *cp++; - else + if (*cp == ',' || *cp == ';' || *cp == ':') { + data.header.separator = *cp; + ++cp; + } else { data.header.separator = ','; + } data.header.element = cp; diff --git a/src/fqdncache.cc b/src/fqdncache.cc index e17ae7ae19..0bb40a85c9 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -455,7 +455,8 @@ fqdncacheParse(fqdncache_entry *f, const rfc1035_rr * answers, int nr, const cha continue; } - f->names[f->name_count++] = xstrdup(answers[k].rdata); + f->names[f->name_count] = xstrdup(answers[k].rdata); + ++ f->name_count; } else if (answers[k].type != RFC1035_TYPE_CNAME) continue; diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 33467c41eb..ef183af471 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -1145,7 +1145,8 @@ UFSSwapDir::DirClean(int swap_index) if (UFSSwapDir::FilenoBelongsHere(fn, D0, D1, D2)) continue; - files[k++] = swapfileno; + files[k] = swapfileno; + ++k; } closedir(dir_pointer); @@ -1201,7 +1202,8 @@ UFSSwapDir::CleanEvent(void *unused) assert (usd); - UFSDirToGlobalDirMapping[n++] = i; + UFSDirToGlobalDirMapping[n] = i; + ++n; j += (usd->l1 * usd->l2); } diff --git a/src/ftp.cc b/src/ftp.cc index e440e418dc..18c7ee80a2 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -779,8 +779,10 @@ ftpListParseParts(const char *buf, struct _ftp_flags flags) return p; } - for (t = strtok(xbuf, w_space); t && n_tokens < MAX_TOKENS; t = strtok(NULL, w_space)) - tokens[n_tokens++] = xstrdup(t); + for (t = strtok(xbuf, w_space); t && n_tokens < MAX_TOKENS; t = strtok(NULL, w_space)) { + tokens[n_tokens] = xstrdup(t); + ++n_tokens; + } xfree(xbuf); @@ -1564,13 +1566,17 @@ escapeIAC(const char *buf) ret = (char *)xmalloc(n); for (p = (unsigned const char *)buf, r=(unsigned char *)ret; *p; ++p) { - *r++ = *p; + *r = *p; + ++r; - if (*p == 255) - *r++ = 255; + if (*p == 255) { + *r = 255; + ++r; + } } - *r++ = '\0'; + *r = '\0'; + ++r; assert((r - (unsigned char *)ret) == n ); return ret; } @@ -2105,8 +2111,10 @@ ftpReadType(FtpStateData * ftpState) d = p; p += strcspn(p, "/"); - if (*p) - *p++ = '\0'; + if (*p) { + *p = '\0'; + ++p; + } rfc1738_unescape(d); diff --git a/src/gopher.cc b/src/gopher.cc index 83b534fd4e..598195adb8 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -498,11 +498,13 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) selector = strchr(tline, TAB); if (selector) { - *selector++ = '\0'; + *selector = '\0'; + ++selector; host = strchr(selector, TAB); if (host) { - *host++ = '\0'; + *host = '\0'; + ++host; port = strchr(host, TAB); if (port) { diff --git a/src/helper.cc b/src/helper.cc index 7ff7b6ebe1..f554ff6478 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -182,12 +182,16 @@ helperOpenServers(helper * hlp) snprintf(procname, strlen(shortname) + 3, "(%s)", shortname); - args[nargs++] = procname; + args[nargs] = procname; + ++nargs; - for (w = hlp->cmdline->next; w && nargs < HELPER_MAX_ARGS; w = w->next) - args[nargs++] = w->key; + for (w = hlp->cmdline->next; w && nargs < HELPER_MAX_ARGS; w = w->next) { + args[nargs] = w->key; + ++nargs; + } - args[nargs++] = NULL; + args[nargs] = NULL; + ++nargs; assert(nargs <= HELPER_MAX_ARGS); @@ -296,12 +300,16 @@ helperStatefulOpenServers(statefulhelper * hlp) snprintf(procname, strlen(shortname) + 3, "(%s)", shortname); - args[nargs++] = procname; + args[nargs] = procname; + ++nargs; - for (wordlist *w = hlp->cmdline->next; w && nargs < HELPER_MAX_ARGS; w = w->next) - args[nargs++] = w->key; + for (wordlist *w = hlp->cmdline->next; w && nargs < HELPER_MAX_ARGS; w = w->next) { + args[nargs] = w->key; + ++nargs; + } - args[nargs++] = NULL; + args[nargs] = NULL; + ++nargs; assert(nargs <= HELPER_MAX_ARGS); @@ -899,7 +907,8 @@ helperHandleRead(const Comm::ConnectionPointer &conn, char *buf, size_t len, com if (t > srv->rbuf && t[-1] == '\r' && hlp->eom == '\n') t[-1] = '\0'; - *t++ = '\0'; + *t = '\0'; + ++t; if (hlp->childs.concurrency) { i = strtol(msg, &msg, 10); diff --git a/src/icmp/net_db.cc b/src/icmp/net_db.cc index bf4def3101..6e88bddfca 100644 --- a/src/icmp/net_db.cc +++ b/src/icmp/net_db.cc @@ -1018,8 +1018,10 @@ netdbDump(StoreEntry * sentry) i = 0; hash_first(addr_table); - while ((n = (netdbEntry *) hash_next(addr_table))) - *(list + i++) = n; + while ((n = (netdbEntry *) hash_next(addr_table))) { + *(list + i) = n; + ++i; + } if (i != memInUse(MEM_NETDBENTRY)) debugs(38, 0, "WARNING: netdb_addrs count off, found " << i << @@ -1245,14 +1247,16 @@ netdbBinaryExchange(StoreEntry * s) if ( !addr.IsIPv4() ) continue; - buf[i++] = (char) NETDB_EX_NETWORK; + buf[i] = (char) NETDB_EX_NETWORK; + ++i; addr.GetInAddr(line_addr); memcpy(&buf[i], &line_addr, sizeof(struct in_addr)); i += sizeof(struct in_addr); - buf[i++] = (char) NETDB_EX_RTT; + buf[i] = (char) NETDB_EX_RTT; + ++i; j = htonl((int) (n->rtt * 1000)); @@ -1260,7 +1264,8 @@ netdbBinaryExchange(StoreEntry * s) i += sizeof(int); - buf[i++] = (char) NETDB_EX_HOPS; + buf[i] = (char) NETDB_EX_HOPS; + ++i; j = htonl((int) (n->hops * 1000)); diff --git a/src/log/ModSyslog.cc b/src/log/ModSyslog.cc index fa7e6dc0b5..77e739e747 100644 --- a/src/log/ModSyslog.cc +++ b/src/log/ModSyslog.cc @@ -178,7 +178,8 @@ logfile_mod_syslog_open(Logfile * lf, const char *path, size_t bufsz, int fatal_ if (!facility) facility = (char *) strchr(priority, '|'); if (facility) { - *facility++ = '\0'; + *facility = '\0'; + ++facility; ll->syslog_priority |= syslog_ntoa(facility); } ll->syslog_priority |= syslog_ntoa(priority); diff --git a/src/ssl/ErrorDetail.cc b/src/ssl/ErrorDetail.cc index 4b6cc06d15..31eb8edf33 100644 --- a/src/ssl/ErrorDetail.cc +++ b/src/ssl/ErrorDetail.cc @@ -140,7 +140,7 @@ static void loadSslErrorMap() static void loadSslErrorShortcutsMap() { assert(TheSslErrorShortcuts.empty()); - for (int i = 0; TheSslErrorShortcutsArray[i].name; i++) + for (int i = 0; TheSslErrorShortcutsArray[i].name; ++i) TheSslErrorShortcuts[TheSslErrorShortcutsArray[i].name] = TheSslErrorShortcutsArray[i].errors; } @@ -178,7 +178,7 @@ Ssl::ParseErrorString(const char *name) // Should not be empty... assert(it->second[0] != SSL_ERROR_NONE); Ssl::Errors *errors = new Ssl::Errors(it->second[0]); - for (int i =1; it->second[i] != SSL_ERROR_NONE; i++) { + for (int i =1; it->second[i] != SSL_ERROR_NONE; ++i) { errors->push_back_unique(it->second[i]); } return errors; diff --git a/src/ssl/context_storage.cc b/src/ssl/context_storage.cc index c3dd114a81..a1ffb0f3e5 100644 --- a/src/ssl/context_storage.cc +++ b/src/ssl/context_storage.cc @@ -171,7 +171,7 @@ void Ssl::GlobalContextStorage::reconfigureFinish() } // add new local storages. - for (std::map::iterator conf_i = configureStorage.begin(); conf_i != configureStorage.end(); conf_i++ ) { + for (std::map::iterator conf_i = configureStorage.begin(); conf_i != configureStorage.end(); ++conf_i ) { if (storage.find(conf_i->first) == storage.end()) { storage.insert(std::pair(conf_i->first, new LocalContextStorage(conf_i->second))); } diff --git a/src/ssl/gadgets.cc b/src/ssl/gadgets.cc index 2133e2e109..4610a7c409 100644 --- a/src/ssl/gadgets.cc +++ b/src/ssl/gadgets.cc @@ -620,7 +620,7 @@ bool Ssl::certificateMatchesProperties(X509 *cert, CertificateProperties const & bool match = true; if (cert1_altnames) { int numalts = sk_GENERAL_NAME_num(cert1_altnames); - for (int i = 0; match && i < numalts; i++) { + for (int i = 0; match && i < numalts; ++i) { const GENERAL_NAME *aName = sk_GENERAL_NAME_value(cert1_altnames, i); match = sk_GENERAL_NAME_find(cert2_altnames, aName); }