Skip to content

Commit 83838d5

Browse files
avargitster
authored andcommitted
cast variable in call to free() in builtin/diff.c and submodule.c
Both of these free() calls are freeing a "const unsigned char (*)[20]" type while free() expects a "void *". This results in the following warning under clang 2.9: builtin/diff.c:185:7: warning: passing 'const unsigned char (*)[20]' to parameter of type 'void *' discards qualifiers free(parent); ^~~~~~ submodule.c:394:7: warning: passing 'const unsigned char (*)[20]' to parameter of type 'void *' discards qualifiers free(parents); ^~~~~~~ This free()-ing without a cast was added by Jim Meyering to builtin/diff.c in v1.7.6-rc3~4 and later by Fredrik Gustafsson in submodule.c in v1.7.7-rc1~25^2. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 473f4c9 commit 83838d5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

builtin/diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static int builtin_diff_combined(struct rev_info *revs,
182182
hashcpy((unsigned char *)(parent + i), ent[i].item->sha1);
183183
diff_tree_combined(parent[0], parent + 1, ents - 1,
184184
revs->dense_combined_merges, revs);
185-
free(parent);
185+
free((void *)parent);
186186
return 0;
187187
}
188188

submodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ static void commit_need_pushing(struct commit *commit, struct commit_list *paren
385385
rev.diffopt.format_callback_data = needs_pushing;
386386
diff_tree_combined(commit->object.sha1, parents, n, 1, &rev);
387387

388-
free(parents);
388+
free((void *)parents);
389389
}
390390

391391
int check_submodule_needs_pushing(unsigned char new_sha1[20], const char *remotes_name)

0 commit comments

Comments
 (0)