All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Kramer <benny.kra@googlemail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH] Fix various dead stores found by the clang static analyzer
Date: Sun, 15 Mar 2009 22:01:20 +0100	[thread overview]
Message-ID: <49BD6CA0.6040909@googlemail.com> (raw)

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, remove unused
                                      assigns
merge-recursive.c::process_renames(): remove unused variable renames2

xdiff/xdiffi.c::xdl_recs_cmp(): ec was unused
xdiff/xemit.c::xdl_emit_diff(): xche is always overwritten

Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com>
---
 http-push.c       |    2 +-
 index-pack.c      |    2 +-
 merge-recursive.c |   11 +++--------
 xdiff/xdiffi.c    |    5 ++---
 xdiff/xemit.c     |    2 +-
 5 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/http-push.c b/http-push.c
index 30d2d34..6715695 100644
--- a/http-push.c
+++ b/http-push.c
@@ -816,7 +816,7 @@ static void finish_request(struct transfer_request *request)
 #ifdef USE_CURL_MULTI
 static int fill_active_slot(void *unused)
 {
-	struct transfer_request *request = request_queue_head;
+	struct transfer_request *request;
 
 	if (aborted)
 		return 0;
diff --git a/index-pack.c b/index-pack.c
index 7fee872..7546822 100644
--- a/index-pack.c
+++ b/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)
 {
-	struct base_data *b = base_cache;
+	struct base_data *b;
 	for (b = base_cache;
 	     base_cache_used > delta_base_cache_limit && b;
 	     b = b->child) {
diff --git a/merge-recursive.c b/merge-recursive.c
index ee853b9..3e1bc3e 100644
--- a/merge-recursive.c
+++ b/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;) {
-		int compare;
 		char *src;
-		struct string_list *renames1, *renames2, *renames2Dst;
+		struct string_list *renames1, *renames2Dst;
 		struct rename *ren1 = NULL, *ren2 = NULL;
 		const char *branch1, *branch2;
 		const char *ren1_src, *ren1_dst;
 
 		if (i >= a_renames->nr) {
-			compare = 1;
 			ren2 = b_renames->items[j++].util;
 		} else if (j >= b_renames->nr) {
-			compare = -1;
 			ren1 = a_renames->items[i++].util;
 		} else {
-			compare = strcmp(a_renames->items[i].string,
-					b_renames->items[j].string);
+			int compare = strcmp(a_renames->items[i].string,
+					     b_renames->items[j].string);
 			if (compare <= 0)
 				ren1 = a_renames->items[i++].util;
 			if (compare >= 0)
@@ -826,14 +823,12 @@ static int process_renames(struct merge_options *o,
 		/* TODO: refactor, so that 1/2 are not needed */
 		if (ren1) {
 			renames1 = a_renames;
-			renames2 = b_renames;
 			renames2Dst = &b_by_dst;
 			branch1 = o->branch1;
 			branch2 = o->branch2;
 		} else {
 			struct rename *tmp;
 			renames1 = b_renames;
-			renames2 = a_renames;
 			renames2Dst = &a_by_dst;
 			branch1 = o->branch2;
 			branch2 = o->branch1;
diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c
index 3e97462..02184d9 100644
--- a/xdiff/xdiffi.c
+++ b/xdiff/xdiffi.c
@@ -293,15 +293,14 @@ int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1,
 		for (; off1 < lim1; off1++)
 			rchg1[rindex1[off1]] = 1;
 	} else {
-		long ec;
 		xdpsplit_t spl;
 		spl.i1 = spl.i2 = 0;
 
 		/*
 		 * Divide ...
 		 */
-		if ((ec = xdl_split(ha1, off1, lim1, ha2, off2, lim2, kvdf, kvdb,
-				    need_min, &spl, xenv)) < 0) {
+		if (xdl_split(ha1, off1, lim1, ha2, off2, lim2, kvdf, kvdb,
+			      need_min, &spl, xenv) < 0) {
 
 			return -1;
 		}
diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index 05bfa41..c4bedf0 100644
--- a/xdiff/xemit.c
+++ b/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)
 		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);
 
 		s1 = XDL_MAX(xch->i1 - xecfg->ctxlen, 0);
-- 
1.6.2.173.g9e85

                 reply	other threads:[~2009-03-15 21:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49BD6CA0.6040909@googlemail.com \
    --to=benny.kra@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.