{"thread":{"id":"18316","subject":"[PATCH] Fix various dead stores found by the clang static analyzer","startedAt":"2009-03-15T21:01:20Z","lastAt":"2009-03-15T21:01:20Z","messageCount":1,"participants":["Benjamin Kramer"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"108056","messageId":"49BD6CA0.6040909@googlemail.com","threadId":"18316","inReplyTo":null,"subject":"[PATCH] Fix various dead stores found by the clang static analyzer","fromName":"Benjamin Kramer","fromEmail":"benny.kra@googlemail.com","sentAt":"2009-03-15T21:01:20Z","receivedAt":"2009-03-15T21:01:20Z","isPatch":true,"sender":{"key":"benny.kra@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/16542?v=4"},"body":"http-push.c::finish_request(): request is initialized by the for loop\nindex-pack.c::free_base_data(): b is initialized by the for loop\n\nmerge-recursive.c::process_renames(): move compare, remove unused\n                                      assigns\nmerge-recursive.c::process_renames(): remove unused variable renames2\n\nxdiff/xdiffi.c::xdl_recs_cmp(): ec was unused\nxdiff/xemit.c::xdl_emit_diff(): xche is always overwritten\n\nSigned-off-by: Benjamin Kramer <benny.kra@googlemail.com>\n---\n http-push.c       |    2 +-\n index-pack.c      |    2 +-\n merge-recursive.c |   11 +++--------\n xdiff/xdiffi.c    |    5 ++---\n xdiff/xemit.c     |    2 +-\n 5 files changed, 8 insertions(+), 14 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 30d2d34..6715695 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -816,7 +816,7 @@ static void finish_request(struct transfer_request *request)\n #ifdef USE_CURL_MULTI\n static int fill_active_slot(void *unused)\n {\n-\tstruct transfer_request *request = request_queue_head;\n+\tstruct transfer_request *request;\n \n \tif (aborted)\n \t\treturn 0;\ndiff --git a/index-pack.c b/index-pack.c\nindex 7fee872..7546822 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -232,7 +232,7 @@ static void free_base_data(struct base_data *c)\n \n static void prune_base_data(struct base_data *retain)\n {\n-\tstruct base_data *b = base_cache;\n+\tstruct base_data *b;\n \tfor (b = base_cache;\n \t     base_cache_used > delta_base_cache_limit && b;\n \t     b = b->child) {\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex ee853b9..3e1bc3e 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -801,22 +801,19 @@ static int process_renames(struct merge_options *o,\n \t}\n \n \tfor (i = 0, j = 0; i < a_renames->nr || j < b_renames->nr;) {\n-\t\tint compare;\n \t\tchar *src;\n-\t\tstruct string_list *renames1, *renames2, *renames2Dst;\n+\t\tstruct string_list *renames1, *renames2Dst;\n \t\tstruct rename *ren1 = NULL, *ren2 = NULL;\n \t\tconst char *branch1, *branch2;\n \t\tconst char *ren1_src, *ren1_dst;\n \n \t\tif (i >= a_renames->nr) {\n-\t\t\tcompare = 1;\n \t\t\tren2 = b_renames->items[j++].util;\n \t\t} else if (j >= b_renames->nr) {\n-\t\t\tcompare = -1;\n \t\t\tren1 = a_renames->items[i++].util;\n \t\t} else {\n-\t\t\tcompare = strcmp(a_renames->items[i].string,\n-\t\t\t\t\tb_renames->items[j].string);\n+\t\t\tint compare = strcmp(a_renames->items[i].string,\n+\t\t\t\t\t     b_renames->items[j].string);\n \t\t\tif (compare <= 0)\n \t\t\t\tren1 = a_renames->items[i++].util;\n \t\t\tif (compare >= 0)\n@@ -826,14 +823,12 @@ static int process_renames(struct merge_options *o,\n \t\t/* TODO: refactor, so that 1/2 are not needed */\n \t\tif (ren1) {\n \t\t\trenames1 = a_renames;\n-\t\t\trenames2 = b_renames;\n \t\t\trenames2Dst = &b_by_dst;\n \t\t\tbranch1 = o->branch1;\n \t\t\tbranch2 = o->branch2;\n \t\t} else {\n \t\t\tstruct rename *tmp;\n \t\t\trenames1 = b_renames;\n-\t\t\trenames2 = a_renames;\n \t\t\trenames2Dst = &a_by_dst;\n \t\t\tbranch1 = o->branch2;\n \t\t\tbranch2 = o->branch1;\ndiff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c\nindex 3e97462..02184d9 100644\n--- a/xdiff/xdiffi.c\n+++ b/xdiff/xdiffi.c\n@@ -293,15 +293,14 @@ int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1,\n \t\tfor (; off1 < lim1; off1++)\n \t\t\trchg1[rindex1[off1]] = 1;\n \t} else {\n-\t\tlong ec;\n \t\txdpsplit_t spl;\n \t\tspl.i1 = spl.i2 = 0;\n \n \t\t/*\n \t\t * Divide ...\n \t\t */\n-\t\tif ((ec = xdl_split(ha1, off1, lim1, ha2, off2, lim2, kvdf, kvdb,\n-\t\t\t\t    need_min, &spl, xenv)) < 0) {\n+\t\tif (xdl_split(ha1, off1, lim1, ha2, off2, lim2, kvdf, kvdb,\n+\t\t\t      need_min, &spl, xenv) < 0) {\n \n \t\t\treturn -1;\n \t\t}\ndiff --git a/xdiff/xemit.c b/xdiff/xemit.c\nindex 05bfa41..c4bedf0 100644\n--- a/xdiff/xemit.c\n+++ b/xdiff/xemit.c\n@@ -132,7 +132,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,\n \tif (xecfg->flags & XDL_EMIT_COMMON)\n \t\treturn xdl_emit_common(xe, xscr, ecb, xecfg);\n \n-\tfor (xch = xche = xscr; xch; xch = xche->next) {\n+\tfor (xch = xscr; xch; xch = xche->next) {\n \t\txche = xdl_get_hunk(xch, xecfg);\n \n \t\ts1 = XDL_MAX(xch->i1 - xecfg->ctxlen, 0);\n-- \n1.6.2.173.g9e85\n"}]}