Skip to content

Commit 8e24cba

Browse files
d0kgitster
authored andcommitted
Fix various dead stores found by the clang static analyzer
http-push.c::finish_request(): request is initialized by the for loop index-pack.c::free_base_data(): b is initialized by the for loop merge-recursive.c::process_renames(): move compare to narrower scope, and remove unused assignments to it remove unused variable renames2 xdiff/xdiffi.c::xdl_recs_cmp(): remove unused variable ec xdiff/xemit.c::xdl_emit_diff(): xche is always overwritten Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent de76978 commit 8e24cba

File tree

5 files changed

+8
-14
lines changed

5 files changed

+8
-14
lines changed

http-push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ static void finish_request(struct transfer_request *request)
816816
#ifdef USE_CURL_MULTI
817817
static int fill_active_slot(void *unused)
818818
{
819-
struct transfer_request *request = request_queue_head;
819+
struct transfer_request *request;
820820

821821
if (aborted)
822822
return 0;

index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static void free_base_data(struct base_data *c)
232232

233233
static void prune_base_data(struct base_data *retain)
234234
{
235-
struct base_data *b = base_cache;
235+
struct base_data *b;
236236
for (b = base_cache;
237237
base_cache_used > delta_base_cache_limit && b;
238238
b = b->child) {

merge-recursive.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -801,22 +801,19 @@ static int process_renames(struct merge_options *o,
801801
}
802802

803803
for (i = 0, j = 0; i < a_renames->nr || j < b_renames->nr;) {
804-
int compare;
805804
char *src;
806-
struct string_list *renames1, *renames2, *renames2Dst;
805+
struct string_list *renames1, *renames2Dst;
807806
struct rename *ren1 = NULL, *ren2 = NULL;
808807
const char *branch1, *branch2;
809808
const char *ren1_src, *ren1_dst;
810809

811810
if (i >= a_renames->nr) {
812-
compare = 1;
813811
ren2 = b_renames->items[j++].util;
814812
} else if (j >= b_renames->nr) {
815-
compare = -1;
816813
ren1 = a_renames->items[i++].util;
817814
} else {
818-
compare = strcmp(a_renames->items[i].string,
819-
b_renames->items[j].string);
815+
int compare = strcmp(a_renames->items[i].string,
816+
b_renames->items[j].string);
820817
if (compare <= 0)
821818
ren1 = a_renames->items[i++].util;
822819
if (compare >= 0)
@@ -826,14 +823,12 @@ static int process_renames(struct merge_options *o,
826823
/* TODO: refactor, so that 1/2 are not needed */
827824
if (ren1) {
828825
renames1 = a_renames;
829-
renames2 = b_renames;
830826
renames2Dst = &b_by_dst;
831827
branch1 = o->branch1;
832828
branch2 = o->branch2;
833829
} else {
834830
struct rename *tmp;
835831
renames1 = b_renames;
836-
renames2 = a_renames;
837832
renames2Dst = &a_by_dst;
838833
branch1 = o->branch2;
839834
branch2 = o->branch1;

xdiff/xdiffi.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,14 @@ int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1,
293293
for (; off1 < lim1; off1++)
294294
rchg1[rindex1[off1]] = 1;
295295
} else {
296-
long ec;
297296
xdpsplit_t spl;
298297
spl.i1 = spl.i2 = 0;
299298

300299
/*
301300
* Divide ...
302301
*/
303-
if ((ec = xdl_split(ha1, off1, lim1, ha2, off2, lim2, kvdf, kvdb,
304-
need_min, &spl, xenv)) < 0) {
302+
if (xdl_split(ha1, off1, lim1, ha2, off2, lim2, kvdf, kvdb,
303+
need_min, &spl, xenv) < 0) {
305304

306305
return -1;
307306
}

xdiff/xemit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
132132
if (xecfg->flags & XDL_EMIT_COMMON)
133133
return xdl_emit_common(xe, xscr, ecb, xecfg);
134134

135-
for (xch = xche = xscr; xch; xch = xche->next) {
135+
for (xch = xscr; xch; xch = xche->next) {
136136
xche = xdl_get_hunk(xch, xecfg);
137137

138138
s1 = XDL_MAX(xch->i1 - xecfg->ctxlen, 0);

0 commit comments

Comments
 (0)