@matheusbsbs / matheus-bagliano / commits / fd13b21f52
Fork 0

Move local variables to narrower scopes

These weren't used outside and can be safely moved Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Benjamin Kramer committed Mar 7, 2009 at 21:02 UTC fd13b21f52b499ff6fa951ce27d4b9c9f0653087
4 files changed +8 -12
builtin-fmt-merge-msg.c
+2 -4
@@ -256,8 +256,7 @@ static void shortlog(const char *name, unsigned char *sha1,
256
257 int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
258 int limit = 20, i = 0, pos = 0;
259 - char line[1024];
260 - char *p = line, *sep = "";
259 + char *sep = "";
260 unsigned char head_sha1[20];
261 const char *current_branch;
262
@@ -271,9 +270,8 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
270 /* get a line */
271 while (pos < in->len) {
272 int len;
274 - char *newline;
273 + char *newline, *p = in->buf + pos;
274
276 - p = in->buf + pos;
275 newline = strchr(p, '\n');
276 len = newline ? newline - p : strlen(p);
277 pos += len + !!newline;
combine-diff.c
+1 -2
@@ -526,7 +526,6 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
526 return; /* result deleted */
527
528 while (1) {
529 - struct sline *sl = &sline[lno];
529 unsigned long hunk_end;
530 unsigned long rlines;
531 const char *hunk_comment = NULL;
@@ -592,7 +591,7 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
591 struct lline *ll;
592 int j;
593 unsigned long p_mask;
595 - sl = &sline[lno++];
594 + struct sline *sl = &sline[lno++];
595 ll = (sl->flag & no_pre_delete) ? NULL : sl->lost_head;
596 while (ll) {
597 fputs(c_old, stdout);
log-tree.c
+3 -3
@@ -79,18 +79,18 @@ void show_decorations(struct rev_info *opt, struct commit *commit)
79 */
80 static int detect_any_signoff(char *letter, int size)
81 {
82 - char ch, *cp;
82 + char *cp;
83 int seen_colon = 0;
84 int seen_at = 0;
85 int seen_name = 0;
86 int seen_head = 0;
87
88 cp = letter + size;
89 - while (letter <= --cp && (ch = *cp) == '\n')
89 + while (letter <= --cp && *cp == '\n')
90 continue;
91
92 while (letter <= cp) {
93 - ch = *cp--;
93 + char ch = *cp--;
94 if (ch == '\n')
95 break;
96
upload-pack.c
+2 -3
@@ -397,12 +397,11 @@ static int get_common_commits(void)
397 static char line[1000];
398 unsigned char sha1[20];
399 char hex[41], last_hex[41];
400 - int len;
400
401 save_commit_buffer = 0;
402
403 for(;;) {
405 - len = packet_read_line(0, line, sizeof(line));
404 + int len = packet_read_line(0, line, sizeof(line));
405 reset_timeout();
406
407 if (!len) {
@@ -410,7 +409,7 @@ static int get_common_commits(void)
409 packet_write(1, "NAK\n");
410 continue;
411 }
413 - len = strip(line, len);
412 + strip(line, len);
413 if (!prefixcmp(line, "have ")) {
414 switch (got_sha1(line+5, sha1)) {
415 case -1: /* they have what we do not */