Browse Source

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>
maint
Benjamin Kramer 16 years ago committed by Junio C Hamano
parent
commit
8e24cbaeaf
  1. 2
      http-push.c
  2. 2
      index-pack.c
  3. 11
      merge-recursive.c
  4. 5
      xdiff/xdiffi.c
  5. 2
      xdiff/xemit.c

2
http-push.c

@ -816,7 +816,7 @@ static void finish_request(struct transfer_request *request)
#ifdef USE_CURL_MULTI #ifdef USE_CURL_MULTI
static int fill_active_slot(void *unused) static int fill_active_slot(void *unused)
{ {
struct transfer_request *request = request_queue_head; struct transfer_request *request;


if (aborted) if (aborted)
return 0; return 0;

2
index-pack.c

@ -232,7 +232,7 @@ static void free_base_data(struct base_data *c)


static void prune_base_data(struct base_data *retain) static void prune_base_data(struct base_data *retain)
{ {
struct base_data *b = base_cache; struct base_data *b;
for (b = base_cache; for (b = base_cache;
base_cache_used > delta_base_cache_limit && b; base_cache_used > delta_base_cache_limit && b;
b = b->child) { b = b->child) {

11
merge-recursive.c

@ -801,22 +801,19 @@ static int process_renames(struct merge_options *o,
} }


for (i = 0, j = 0; i < a_renames->nr || j < b_renames->nr;) { for (i = 0, j = 0; i < a_renames->nr || j < b_renames->nr;) {
int compare;
char *src; char *src;
struct string_list *renames1, *renames2, *renames2Dst; struct string_list *renames1, *renames2Dst;
struct rename *ren1 = NULL, *ren2 = NULL; struct rename *ren1 = NULL, *ren2 = NULL;
const char *branch1, *branch2; const char *branch1, *branch2;
const char *ren1_src, *ren1_dst; const char *ren1_src, *ren1_dst;


if (i >= a_renames->nr) { if (i >= a_renames->nr) {
compare = 1;
ren2 = b_renames->items[j++].util; ren2 = b_renames->items[j++].util;
} else if (j >= b_renames->nr) { } else if (j >= b_renames->nr) {
compare = -1;
ren1 = a_renames->items[i++].util; ren1 = a_renames->items[i++].util;
} else { } else {
compare = strcmp(a_renames->items[i].string, int compare = strcmp(a_renames->items[i].string,
b_renames->items[j].string); b_renames->items[j].string);
if (compare <= 0) if (compare <= 0)
ren1 = a_renames->items[i++].util; ren1 = a_renames->items[i++].util;
if (compare >= 0) if (compare >= 0)
@ -826,14 +823,12 @@ static int process_renames(struct merge_options *o,
/* TODO: refactor, so that 1/2 are not needed */ /* TODO: refactor, so that 1/2 are not needed */
if (ren1) { if (ren1) {
renames1 = a_renames; renames1 = a_renames;
renames2 = b_renames;
renames2Dst = &b_by_dst; renames2Dst = &b_by_dst;
branch1 = o->branch1; branch1 = o->branch1;
branch2 = o->branch2; branch2 = o->branch2;
} else { } else {
struct rename *tmp; struct rename *tmp;
renames1 = b_renames; renames1 = b_renames;
renames2 = a_renames;
renames2Dst = &a_by_dst; renames2Dst = &a_by_dst;
branch1 = o->branch2; branch1 = o->branch2;
branch2 = o->branch1; branch2 = o->branch1;

5
xdiff/xdiffi.c

@ -293,15 +293,14 @@ int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1,
for (; off1 < lim1; off1++) for (; off1 < lim1; off1++)
rchg1[rindex1[off1]] = 1; rchg1[rindex1[off1]] = 1;
} else { } else {
long ec;
xdpsplit_t spl; xdpsplit_t spl;
spl.i1 = spl.i2 = 0; spl.i1 = spl.i2 = 0;


/* /*
* Divide ... * Divide ...
*/ */
if ((ec = xdl_split(ha1, off1, lim1, ha2, off2, lim2, kvdf, kvdb, if (xdl_split(ha1, off1, lim1, ha2, off2, lim2, kvdf, kvdb,
need_min, &spl, xenv)) < 0) { need_min, &spl, xenv) < 0) {


return -1; return -1;
} }

2
xdiff/xemit.c

@ -132,7 +132,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
if (xecfg->flags & XDL_EMIT_COMMON) if (xecfg->flags & XDL_EMIT_COMMON)
return xdl_emit_common(xe, xscr, ecb, xecfg); return xdl_emit_common(xe, xscr, ecb, xecfg);


for (xch = xche = xscr; xch; xch = xche->next) { for (xch = xscr; xch; xch = xche->next) {
xche = xdl_get_hunk(xch, xecfg); xche = xdl_get_hunk(xch, xecfg);


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

Loading…
Cancel
Save