Browse Source

builtin/apply: avoid local variable shadowing 'len' parameter

This is just a cleanup to avoid errors when compiling with -Wshadow and
to make it safer to later move global variables into a "state" struct.

Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Christian Couder 9 years ago committed by Junio C Hamano
parent
commit
bb0ba99743
  1. 20
      builtin/apply.c

20
builtin/apply.c

@ -2194,17 +2194,17 @@ static void update_pre_post_images(struct image *preimage, @@ -2194,17 +2194,17 @@ static void update_pre_post_images(struct image *preimage,
fixed = preimage->buf;

for (i = reduced = ctx = 0; i < postimage->nr; i++) {
size_t len = postimage->line[i].len;
size_t l_len = postimage->line[i].len;
if (!(postimage->line[i].flag & LINE_COMMON)) {
/* an added line -- no counterparts in preimage */
memmove(new, old, len);
old += len;
new += len;
memmove(new, old, l_len);
old += l_len;
new += l_len;
continue;
}

/* a common context -- skip it in the original postimage */
old += len;
old += l_len;

/* and find the corresponding one in the fixed preimage */
while (ctx < preimage->nr &&
@ -2223,11 +2223,11 @@ static void update_pre_post_images(struct image *preimage, @@ -2223,11 +2223,11 @@ static void update_pre_post_images(struct image *preimage,
}

/* and copy it in, while fixing the line length */
len = preimage->line[ctx].len;
memcpy(new, fixed, len);
new += len;
fixed += len;
postimage->line[i].len = len;
l_len = preimage->line[ctx].len;
memcpy(new, fixed, l_len);
new += l_len;
fixed += l_len;
postimage->line[i].len = l_len;
ctx++;
}


Loading…
Cancel
Save