Skip to content

Commit 18bc8eb

Browse files
peffdscho
authored andcommitted
range-diff: drop useless "offset" variable from read_patches()
The "offset" variable was was introduced in 44b67cb (range-diff: split lines manually, 2019-07-11), but it has never done anything useful. We use it to count up the number of bytes we've consumed, but we never look at the result. It was probably copied accidentally from an almost-identical loop in apply.c:find_header() (and the point of that commit was to make use of the parse_git_diff_header() function which underlies both). Because the variable was set but not used, most compilers didn't seem to notice, but the upcoming clang-14 does complain about it, via its -Wunused-but-set-variable warning. Signed-off-by: Jeff King <[email protected]> Acked-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 394a759 commit 18bc8eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

range-diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static int read_patches(const char *range, struct string_list *list,
4848
struct patch_util *util = NULL;
4949
int in_header = 1;
5050
char *line, *current_filename = NULL;
51-
int offset, len;
51+
int len;
5252
size_t size;
5353

5454
strvec_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
@@ -83,7 +83,7 @@ static int read_patches(const char *range, struct string_list *list,
8383

8484
line = contents.buf;
8585
size = contents.len;
86-
for (offset = 0; size > 0; offset += len, size -= len, line += len) {
86+
for (; size > 0; size -= len, line += len) {
8787
const char *p;
8888

8989
len = find_end_of_line(line, size);

0 commit comments

Comments
 (0)