From c01499ef6933bd0e3fc65277559dc80f13d6a49e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 16 Oct 2013 10:26:39 -0700 Subject: C: have space around && and || operators Correct all hits from git grep -e '\(&&\|||\)[^ ]' -e '[^ ]\(&&\|||\)' -- '*.c' i.e. && or || operators that are followed by anything but a SP, or that follow something other than a SP or a HT, so that these operators have a SP around it when necessary. We usually refrain from making this kind of a tree-wide change in order to avoid unnecessary conflicts with other "real work" patches, but in this case, the end result does not have a potentially cumbersome tree-wide impact, while this is a tree-wide cleanup. Fixes to compat/regex/regcomp.c and xdiff/xemit.c are to replace a HT immediately after && with a SP. This is based on Felipe's patch to bultin/symbolic-ref.c; I did all the finding out what other files in the whole tree need to be fixed and did the fix and also the log message while reviewing that single liner, so any screw-ups in this version are mine. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- builtin/read-tree.c | 2 +- builtin/rev-list.c | 2 +- builtin/symbolic-ref.c | 2 +- compat/regex/regcomp.c | 2 +- xdiff/xemit.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/read-tree.c b/builtin/read-tree.c index 0f5d7fe23f..0d7ef847a7 100644 --- a/builtin/read-tree.c +++ b/builtin/read-tree.c @@ -178,7 +178,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix) if (1 < opts.index_only + opts.update) die("-u and -i at the same time makes no sense"); - if ((opts.update||opts.index_only) && !opts.merge) + if ((opts.update || opts.index_only) && !opts.merge) die("%s is meaningless without -m, --reset, or --prefix", opts.update ? "-u" : "-i"); if ((opts.dir && !opts.update)) diff --git a/builtin/rev-list.c b/builtin/rev-list.c index 4fc1616637..0745e2d053 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -322,7 +322,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) revs.commit_format = CMIT_FMT_RAW; if ((!revs.commits && - (!(revs.tag_objects||revs.tree_objects||revs.blob_objects) && + (!(revs.tag_objects || revs.tree_objects || revs.blob_objects) && !revs.pending.nr)) || revs.diff) usage(rev_list_usage); diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c index f481959421..71286b4fae 100644 --- a/builtin/symbolic-ref.c +++ b/builtin/symbolic-ref.c @@ -47,7 +47,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix) git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, options, git_symbolic_ref_usage, 0); - if (msg &&!*msg) + if (msg && !*msg) die("Refusing to perform update with empty message"); if (delete) { diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c index b2c5d465ac..06f3088708 100644 --- a/compat/regex/regcomp.c +++ b/compat/regex/regcomp.c @@ -339,7 +339,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, p = buf; *p++ = dfa->nodes[node].opr.c; while (++node < dfa->nodes_len - && dfa->nodes[node].type == CHARACTER + && dfa->nodes[node].type == CHARACTER && dfa->nodes[node].mb_partial) *p++ = dfa->nodes[node].opr.c; memset (&state, '\0', sizeof (state)); diff --git a/xdiff/xemit.c b/xdiff/xemit.c index 4d8645867e..4266ada23f 100644 --- a/xdiff/xemit.c +++ b/xdiff/xemit.c @@ -108,7 +108,7 @@ static long def_ff(const char *rec, long len, char *buf, long sz, void *priv) { if (len > 0 && (isalpha((unsigned char)*rec) || /* identifier? */ - *rec == '_' || /* also identifier? */ + *rec == '_' || /* also identifier? */ *rec == '$')) { /* identifiers from VMS and other esoterico */ if (len > sz) len = sz; -- cgit v1.2.3 From cc10837929b2afe4116bb305e69b4bd4a95958de Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 21 Sep 2013 14:15:44 -0500 Subject: alias: have SP around arithmetic operators Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- alias.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/alias.c b/alias.c index eb9f08b912..9938f03c25 100644 --- a/alias.c +++ b/alias.c @@ -5,7 +5,7 @@ static char *alias_val; static int alias_lookup_cb(const char *k, const char *v, void *cb) { - if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) { + if (!prefixcmp(k, "alias.") && !strcmp(k + 6, alias_key)) { if (!v) return config_error_nonbool(k); alias_val = xstrdup(v); @@ -34,7 +34,7 @@ int split_cmdline(char *cmdline, const char ***argv) int src, dst, count = 0, size = 16; char quoted = 0; - *argv = xmalloc(sizeof(char *) * size); + *argv = xmalloc(sizeof(**argv) * size); /* split alias_string */ (*argv)[count++] = cmdline; @@ -45,7 +45,7 @@ int split_cmdline(char *cmdline, const char ***argv) while (cmdline[++src] && isspace(cmdline[src])) ; /* skip */ - ALLOC_GROW(*argv, count+1, size); + ALLOC_GROW(*argv, count + 1, size); (*argv)[count++] = cmdline + dst; } else if (!quoted && (c == '\'' || c == '"')) { quoted = c; @@ -76,12 +76,13 @@ int split_cmdline(char *cmdline, const char ***argv) return -SPLIT_CMDLINE_UNCLOSED_QUOTE; } - ALLOC_GROW(*argv, count+1, size); + ALLOC_GROW(*argv, count + 1, size); (*argv)[count] = NULL; return count; } -const char *split_cmdline_strerror(int split_cmdline_errno) { - return split_cmdline_errors[-split_cmdline_errno-1]; +const char *split_cmdline_strerror(int split_cmdline_errno) +{ + return split_cmdline_errors[-split_cmdline_errno - 1]; } -- cgit v1.2.3 From f1e835fa1375f3e1c60eedc87012d1a9c96ce511 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 15 Oct 2013 15:25:45 -0700 Subject: abspath.c: have SP around arithmetic operators Signed-off-by: Junio C Hamano --- abspath.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/abspath.c b/abspath.c index 64adbe2a1b..e390994abf 100644 --- a/abspath.c +++ b/abspath.c @@ -110,7 +110,7 @@ static const char *real_path_internal(const char *path, int die_on_error) else goto error_out; } - if (len && !is_dir_sep(buf[len-1])) + if (len && !is_dir_sep(buf[len - 1])) buf[len++] = '/'; strcpy(buf + len, last_elem); free(last_elem); @@ -201,7 +201,7 @@ const char *absolute_path(const char *path) if (!cwd) die_errno("Cannot determine the current working directory"); len = strlen(cwd); - fmt = (len > 0 && is_dir_sep(cwd[len-1])) ? "%s%s" : "%s/%s"; + fmt = (len > 0 && is_dir_sep(cwd[len - 1])) ? "%s%s" : "%s/%s"; if (snprintf(buf, PATH_MAX, fmt, cwd, path) >= PATH_MAX) die("Too long path: %.*s", 60, path); } -- cgit v1.2.3 From ea6640ec3eb31191bafa6ed4d874d731173e1c15 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 15 Oct 2013 15:25:53 -0700 Subject: alloc.c: have SP around arithmetic operators Signed-off-by: Junio C Hamano --- alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alloc.c b/alloc.c index aeae55c976..f3ee745695 100644 --- a/alloc.c +++ b/alloc.c @@ -58,7 +58,7 @@ static void report(const char *name, unsigned int count, size_t size) } #define REPORT(name) \ - report(#name, name##_allocs, name##_allocs*sizeof(struct name) >> 10) + report(#name, name##_allocs, name##_allocs * sizeof(struct name) >> 10) void alloc_report(void) { -- cgit v1.2.3 From b1cdfb54f10ca64dc57be0d9184dcb4c9c069eac Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 15 Oct 2013 15:27:17 -0700 Subject: archive.c: have SP around arithmetic operators Signed-off-by: Junio C Hamano --- archive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archive.c b/archive.c index 99fadc88d0..346f3b2f1a 100644 --- a/archive.c +++ b/archive.c @@ -440,7 +440,7 @@ static int match_extension(const char *filename, const char *ext) * prefix is non-empty (k.e., we don't match .tar.gz with no actual * filename). */ - if (prefixlen < 2 || filename[prefixlen-1] != '.') + if (prefixlen < 2 || filename[prefixlen - 1] != '.') return 0; return !strcmp(filename + prefixlen, ext); } -- cgit v1.2.3 From 5f050e3c4ce05de13f24157ca7d3452362e673dc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 15 Oct 2013 15:27:34 -0700 Subject: base85.c: have SP around arithmetic operators Signed-off-by: Junio C Hamano --- base85.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base85.c b/base85.c index 781b5754f0..5ca601ee14 100644 --- a/base85.c +++ b/base85.c @@ -41,7 +41,7 @@ int decode_85(char *dst, const char *buffer, int len) { prep_base85(); - say2("decode 85 <%.*s>", len/4*5, buffer); + say2("decode 85 <%.*s>", len / 4 * 5, buffer); while (len) { unsigned acc = 0; int de, cnt = 4; -- cgit v1.2.3 From 6b2dd0e56ba2bd668396afe9e983dddfd1f441ca Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 15 Oct 2013 15:27:51 -0700 Subject: block-sha1/sha1.c: have SP around arithmetic operators Signed-off-by: Junio C Hamano --- block-sha1/sha1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c index a8d4bf9301..e1a1eb6097 100644 --- a/block-sha1/sha1.c +++ b/block-sha1/sha1.c @@ -274,10 +274,10 @@ void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx) padlen[1] = htonl((uint32_t)(ctx->size << 3)); i = ctx->size & 63; - blk_SHA1_Update(ctx, pad, 1+ (63 & (55 - i))); + blk_SHA1_Update(ctx, pad, 1 + (63 & (55 - i))); blk_SHA1_Update(ctx, padlen, 8); /* Output hash */ for (i = 0; i < 5; i++) - put_be32(hashout + i*4, ctx->H[i]); + put_be32(hashout + i * 4, ctx->H[i]); } -- cgit v1.2.3