From af1077dd757ca5524bed2138ff0d9926b516c6f1 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Thu, 7 Mar 2019 03:28:31 +0000 Subject: [PATCH] fix pre-increment in for loops In for loops, there's no difference in behaviour between: `for (int i = 0; i < 10; ++i)` `for (int i = 0; i < 10; i++)` Use the C form, `i++`, for consistency. --- email/parse.c | 2 +- email/rfc2047.c | 2 +- hcache/hcache.c | 4 ++-- imap/auth.c | 4 ++-- keymap.c | 12 ++++++------ monitor.c | 6 +++--- mutt/regex.c | 2 +- mutt/string.c | 2 +- muttlib.c | 2 +- pattern.c | 2 +- sendlib.c | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/email/parse.c b/email/parse.c index c6c19f601..fdabd79c4 100644 --- a/email/parse.c +++ b/email/parse.c @@ -344,7 +344,7 @@ char *mutt_extract_message_id(const char *s, const char **saveptr) else return NULL; - for (s = NULL, o = NULL, onull = NULL; (p = strpbrk(p, "<> \t;")); ++p) + for (s = NULL, o = NULL, onull = NULL; (p = strpbrk(p, "<> \t;")); p++) { if (*p == '<') { diff --git a/email/rfc2047.c b/email/rfc2047.c index 46a8ddb43..2677bd673 100644 --- a/email/rfc2047.c +++ b/email/rfc2047.c @@ -374,7 +374,7 @@ static char *decode_word(const char *s, size_t len, enum ContentEncoding enc) if (enc == ENC_QUOTED_PRINTABLE) { struct Buffer buf = { 0 }; - for (; it < end; ++it) + for (; it < end; it++) { if (*it == '_') { diff --git a/hcache/hcache.c b/hcache/hcache.c index 4598552d1..87e4d928f 100644 --- a/hcache/hcache.c +++ b/hcache/hcache.c @@ -112,7 +112,7 @@ static const struct HcacheOps *hcache_get_backend_ops(const char *backend) return *ops; } - for (; *ops; ++ops) + for (; *ops; ops++) if (strcmp(backend, (*ops)->name) == 0) break; @@ -464,7 +464,7 @@ const char *mutt_hcache_backend_list(void) const struct HcacheOps **ops = hcache_ops; size_t len = 0; - for (; *ops; ++ops) + for (; *ops; ops++) { if (len != 0) { diff --git a/imap/auth.c b/imap/auth.c index 04d30d18d..d370634db 100644 --- a/imap/auth.c +++ b/imap/auth.c @@ -86,7 +86,7 @@ int imap_authenticate(struct ImapAccountData *adata) mutt_debug(LL_DEBUG2, "Trying method %s\n", method); - for (size_t i = 0; i < mutt_array_size(imap_authenticators); ++i) + for (size_t i = 0; i < mutt_array_size(imap_authenticators); i++) { const struct ImapAuth *auth = &imap_authenticators[i]; if (!auth->method || (mutt_str_strcasecmp(auth->method, method) == 0)) @@ -108,7 +108,7 @@ int imap_authenticate(struct ImapAccountData *adata) /* Fall back to default: any authenticator */ mutt_debug(LL_DEBUG2, "Trying pre-defined imap_authenticators.\n"); - for (size_t i = 0; i < mutt_array_size(imap_authenticators); ++i) + for (size_t i = 0; i < mutt_array_size(imap_authenticators); i++) { rc = imap_authenticators[i].authenticate(adata, NULL); if (rc == IMAP_AUTH_SUCCESS) diff --git a/keymap.c b/keymap.c index c7bef9120..6a7027ad0 100644 --- a/keymap.c +++ b/keymap.c @@ -859,7 +859,7 @@ static const struct Extkey ExtKeys[] = { */ static const char *find_ext_name(const char *key) { - for (int j = 0; ExtKeys[j].name; ++j) + for (int j = 0; ExtKeys[j].name; j++) { if (strcasecmp(key, ExtKeys[j].name) == 0) return ExtKeys[j].sym; @@ -884,7 +884,7 @@ void init_extended_keys(void) use_extended_names(true); - for (int j = 0; KeyNames[j].name; ++j) + for (int j = 0; KeyNames[j].name; j++) { if (KeyNames[j].value == -1) { @@ -1266,14 +1266,14 @@ enum CommandResult mutt_parse_bind(struct Buffer *buf, struct Buffer *s, } else if (mutt_str_strcasecmp("noop", buf->data) == 0) { - for (int i = 0; i < nummenus; ++i) + for (int i = 0; i < nummenus; i++) { km_bindkey(key, menu[i], OP_NULL); /* the 'unbind' command */ } } else { - for (int i = 0; i < nummenus; ++i) + for (int i = 0; i < nummenus; i++) { /* The pager and editor menus don't use the generic map, * however for other menus try generic first. */ @@ -1334,7 +1334,7 @@ enum CommandResult mutt_parse_macro(struct Buffer *buf, struct Buffer *s, } else { - for (int i = 0; i < nummenus; ++i) + for (int i = 0; i < nummenus; i++) { rc = km_bind(key, menu[i], OP_MACRO, seq, buf->data); } @@ -1344,7 +1344,7 @@ enum CommandResult mutt_parse_macro(struct Buffer *buf, struct Buffer *s, } else { - for (int i = 0; i < nummenus; ++i) + for (int i = 0; i < nummenus; i++) { rc = km_bind(key, menu[i], OP_MACRO, buf->data, NULL); } diff --git a/monitor.c b/monitor.c index 0b063e904..7340498de 100644 --- a/monitor.c +++ b/monitor.c @@ -103,7 +103,7 @@ struct MonitorInfo static void mutt_poll_fd_add(int fd, short events) { int i = 0; - for (; (i < PollFdsCount) && (PollFds[i].fd != fd); ++i) + for (; (i < PollFdsCount) && (PollFds[i].fd != fd); i++) ; if (i == PollFdsCount) @@ -130,7 +130,7 @@ static void mutt_poll_fd_add(int fd, short events) static int mutt_poll_fd_remove(int fd) { int i = 0; - for (; (i < PollFdsCount) && (PollFds[i].fd != fd); ++i) + for (; (i < PollFdsCount) && (PollFds[i].fd != fd); i++) ; if (i == PollFdsCount) return -1; @@ -380,7 +380,7 @@ int mutt_monitor_poll(void) else { bool inputReady = false; - for (int i = 0; fds && (i < PollFdsCount); ++i) + for (int i = 0; fds && (i < PollFdsCount); i++) { if (PollFds[i].revents) { diff --git a/mutt/regex.c b/mutt/regex.c index 4f6cfe7fe..54046e99d 100644 --- a/mutt/regex.c +++ b/mutt/regex.c @@ -513,7 +513,7 @@ bool mutt_replacelist_match(struct ReplaceList *rl, char *buf, size_t buflen, co * the terminating nul char */ int idx; for (idx = pmatch[n].rm_so; - (idx < pmatch[n].rm_eo) && (tlen < buflen - 1); ++idx) + (idx < pmatch[n].rm_eo) && (tlen < buflen - 1); idx++) { buf[tlen++] = str[idx]; } diff --git a/mutt/string.c b/mutt/string.c index 3d01a03e8..9f5813e72 100644 --- a/mutt/string.c +++ b/mutt/string.c @@ -921,7 +921,7 @@ const char *mutt_str_rstrnstr(const char *haystack, size_t haystack_length, cons for (const char *p = haystack_end; p >= haystack; --p) { - for (size_t i = 0; i < needle_length; ++i) + for (size_t i = 0; i < needle_length; i++) { if (p[i] != needle[i]) goto next; diff --git a/muttlib.c b/muttlib.c index 5dd496449..1613ad930 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1511,7 +1511,7 @@ void mutt_encode_path(char *buf, size_t buflen, const char *src) size_t len = mutt_str_strfcpy(buf, (rc == 0) ? p : src, buflen); /* convert the path to POSIX "Portable Filename Character Set" */ - for (size_t i = 0; i < len; ++i) + for (size_t i = 0; i < len; i++) { if (!isalnum(buf[i]) && !strchr("/.-_", buf[i])) { diff --git a/pattern.c b/pattern.c index 7866e5d44..9529fa5ca 100644 --- a/pattern.c +++ b/pattern.c @@ -1039,7 +1039,7 @@ static bool eat_message_range(struct Pattern *pat, struct Buffer *s, struct Buff skip_quote = true; } - for (int i_kind = 0; i_kind != RANGE_K_INVALID; ++i_kind) + for (int i_kind = 0; i_kind != RANGE_K_INVALID; i_kind++) { switch (eat_range_by_regex(pat, s, i_kind, err)) { diff --git a/sendlib.c b/sendlib.c index ea1bec956..1772dbb5e 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1812,7 +1812,7 @@ void mutt_write_references(const struct ListHead *r, FILE *fp, size_t trim) break; } - for (size_t i = 0; i < length; ++i) + for (size_t i = 0; i < length; i++) { fputc(' ', fp); fputs(ref[i]->data, fp); -- 2.40.0