From: Giuseppe Scrivano <gscrivano@gnu.org>
To: git@vger.kernel.org
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Sverre Rabbelier <srabbelier@gmail.com>
Subject: Re: [PATCH] Remove various dead assignments and dead increments found by the clang static analyzer
Date: Sat, 26 Sep 2009 21:15:58 +0200 [thread overview]
Message-ID: <87ske9cya9.fsf@master.homenet> (raw)
In-Reply-To: <fabb9a1e0909261134qd90dba1n9637fe4adc253fc1@mail.gmail.com> (Sverre Rabbelier's message of "Sat, 26 Sep 2009 20:34:22 +0200")
Here is a cleaned patch. I think these assignments can be removed
without any problem.
Cheers,
Giuseppe
>From 7501d82998132b15ad5cda78c0650f4f4a0b0e93 Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <gscrivano@gnu.org>
Date: Sat, 26 Sep 2009 21:11:21 +0200
Subject: [PATCH] Remove various dead assignments and dead increments found by the clang static analyzer
---
builtin-commit.c | 2 +-
builtin-fetch--tool.c | 2 +-
builtin-fetch-pack.c | 2 +-
builtin-grep.c | 2 --
builtin-pack-objects.c | 2 +-
builtin-receive-pack.c | 8 ++++----
builtin-send-pack.c | 2 +-
builtin-show-branch.c | 4 ++--
color.c | 2 +-
compat/mkstemps.c | 2 +-
connect.c | 1 -
diff.c | 2 +-
http-fetch.c | 3 +--
transport.c | 4 ++--
upload-pack.c | 2 +-
15 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 200ffda..331d2a0 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -1035,7 +1035,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
parents = reduce_heads(parents);
} else {
reflog_msg = "commit";
- pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
+ commit_list_insert(lookup_commit(head_sha1), pptr);
}
/* Finally, get the commit message */
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index 3dbdf7a..c47469f 100644
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
@@ -169,7 +169,7 @@ static int append_fetch_head(FILE *fp,
note_len += sprintf(note + note_len, "%s ", kind);
note_len += sprintf(note + note_len, "'%s' of ", what);
}
- note_len += sprintf(note + note_len, "%.*s", remote_len, remote);
+ sprintf(note + note_len, "%.*s", remote_len, remote);
fprintf(fp, "%s\t%s\t%s\n",
sha1_to_hex(commit ? commit->object.sha1 : sha1),
not_for_merge ? "not-for-merge" : "",
diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c
index 629735f..583f4e3 100644
--- a/builtin-fetch-pack.c
+++ b/builtin-fetch-pack.c
@@ -555,7 +555,7 @@ static int get_pack(int xd[2], char **pack_lockfile)
}
if (*hdr_arg)
*av++ = hdr_arg;
- *av++ = NULL;
+ *av = NULL;
cmd.in = demux.out;
cmd.git_cmd = 1;
diff --git a/builtin-grep.c b/builtin-grep.c
index 761799d..d36b59e 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -400,7 +400,6 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
if (sizeof(randarg) <= len)
die("maximum length of args exceeded");
push_arg(argptr);
- argptr += len;
}
}
else {
@@ -410,7 +409,6 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
if (sizeof(randarg) <= len)
die("maximum length of args exceeded");
push_arg(argptr);
- argptr += len;
}
}
for (p = opt->pattern_list; p; p = p->next) {
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 02f9246..bea7141 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -2307,7 +2307,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
*/
if (!pack_to_stdout)
- base_name = argv[i++];
+ base_name = argv[i];
if (pack_to_stdout != !base_name)
usage(pack_usage);
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c
index b771fe9..82d1564 100644
--- a/builtin-receive-pack.c
+++ b/builtin-receive-pack.c
@@ -368,7 +368,7 @@ static char update_post_hook[] = "hooks/post-update";
static void run_update_post_hook(struct command *cmd)
{
struct command *cmd_p;
- int argc, status;
+ int argc;
const char **argv;
for (argc = 0, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
@@ -391,7 +391,7 @@ static void run_update_post_hook(struct command *cmd)
argc++;
}
argv[argc] = NULL;
- status = run_command_v_opt(argv, RUN_COMMAND_NO_STDIN
+ run_command_v_opt(argv, RUN_COMMAND_NO_STDIN
| RUN_COMMAND_STDOUT_TO_STDERR);
}
@@ -506,7 +506,7 @@ static const char *unpack(void)
if (receive_fsck_objects)
unpacker[i++] = "--strict";
unpacker[i++] = hdr_arg;
- unpacker[i++] = NULL;
+ unpacker[i] = NULL;
code = run_command_v_opt(unpacker, RUN_GIT_CMD);
if (!code)
return NULL;
@@ -528,7 +528,7 @@ static const char *unpack(void)
keeper[i++] = "--fix-thin";
keeper[i++] = hdr_arg;
keeper[i++] = keep_arg;
- keeper[i++] = NULL;
+ keeper[i] = NULL;
memset(&ip, 0, sizeof(ip));
ip.argv = keeper;
ip.out = -1;
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 37e528e..5afd542 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -55,7 +55,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
if (args->use_ofs_delta)
argv[i++] = "--delta-base-offset";
if (args->quiet)
- argv[i++] = "-q";
+ argv[i] = "-q";
memset(&po, 0, sizeof(po));
po.argv = argv;
po.in = -1;
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 3510a86..e567eb5 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -191,9 +191,9 @@ static void name_commits(struct commit_list *list,
break;
}
if (nth == 1)
- en += sprintf(en, "^");
+ sprintf(en, "^");
else
- en += sprintf(en, "^%d", nth);
+ sprintf(en, "^%d", nth);
name_commit(p, xstrdup(newname), 0);
i++;
name_first_parent_chain(p);
diff --git a/color.c b/color.c
index 62977f4..5b31588 100644
--- a/color.c
+++ b/color.c
@@ -110,7 +110,7 @@ void color_parse_mem(const char *value, int value_len, const char *var,
}
}
if (bg >= 0) {
- if (sep++)
+ if (sep)
*dst++ = ';';
if (bg < 8) {
*dst++ = '4';
diff --git a/compat/mkstemps.c b/compat/mkstemps.c
index 14179c8..dbf916e 100644
--- a/compat/mkstemps.c
+++ b/compat/mkstemps.c
@@ -45,7 +45,7 @@ int gitmkstemps(char *pattern, int suffix_len)
template[2] = letters[v % num_letters]; v /= num_letters;
template[3] = letters[v % num_letters]; v /= num_letters;
template[4] = letters[v % num_letters]; v /= num_letters;
- template[5] = letters[v % num_letters]; v /= num_letters;
+ template[5] = letters[v % num_letters];
fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, 0600);
if (fd > 0)
diff --git a/connect.c b/connect.c
index 7945e38..da6c7c1 100644
--- a/connect.c
+++ b/connect.c
@@ -18,7 +18,6 @@ static int check_ref(const char *name, int len, unsigned int flags)
/* Skip the "refs/" part */
name += 5;
- len -= 5;
/* REF_NORMAL means that we don't want the magic fake tag refs */
if ((flags & REF_NORMAL) && check_ref_format(name) < 0)
diff --git a/diff.c b/diff.c
index e1be189..e75f58e 100644
--- a/diff.c
+++ b/diff.c
@@ -901,7 +901,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
/* Find the longest filename and max number of changes */
reset = diff_get_color_opt(options, DIFF_RESET);
- set = diff_get_color_opt(options, DIFF_PLAIN);
+ diff_get_color_opt(options, DIFF_PLAIN);
add_c = diff_get_color_opt(options, DIFF_FILE_NEW);
del_c = diff_get_color_opt(options, DIFF_FILE_OLD);
diff --git a/http-fetch.c b/http-fetch.c
index e8f44ba..6879904 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -3,7 +3,6 @@
int main(int argc, const char **argv)
{
- const char *prefix;
struct walker *walker;
int commits_on_stdin = 0;
int commits;
@@ -19,7 +18,7 @@ int main(int argc, const char **argv)
int get_verbosely = 0;
int get_recover = 0;
- prefix = setup_git_directory();
+ setup_git_directory();
git_config(git_default_config, NULL);
diff --git a/transport.c b/transport.c
index 644a30a..8ec0df6 100644
--- a/transport.c
+++ b/transport.c
@@ -308,7 +308,7 @@ static int rsync_transport_push(struct transport *transport,
args[i++] = "info";
args[i++] = get_object_directory();
args[i++] = buf.buf;
- args[i++] = NULL;
+ args[i] = NULL;
if (run_command(&rsync))
return error("Could not push objects to %s",
@@ -334,7 +334,7 @@ static int rsync_transport_push(struct transport *transport,
args[i++] = "--ignore-existing";
args[i++] = temp_dir.buf;
args[i++] = rsync_url(transport->url);
- args[i++] = NULL;
+ args[i] = NULL;
if (run_command(&rsync))
result = error("Could not push to %s",
rsync_url(transport->url));
diff --git a/upload-pack.c b/upload-pack.c
index 38ddac2..fb3436c 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -241,7 +241,7 @@ static void create_pack_file(void)
argv[arg++] = "--delta-base-offset";
if (use_include_tag)
argv[arg++] = "--include-tag";
- argv[arg++] = NULL;
+ argv[arg] = NULL;
memset(&pack_objects, 0, sizeof(pack_objects));
pack_objects.in = shallow_nr ? rev_list.out : -1;
--
1.6.3.3
next prev parent reply other threads:[~2009-09-26 19:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-26 14:46 [PATCH] Remove various dead assignments and dead increments found by the clang static analyzer Giuseppe Scrivano
2009-09-26 15:58 ` Johannes Schindelin
2009-09-26 18:21 ` Giuseppe Scrivano
2009-09-26 18:34 ` Sverre Rabbelier
2009-09-26 18:46 ` Giuseppe Scrivano
2009-09-26 19:15 ` Giuseppe Scrivano [this message]
2009-09-26 19:28 ` René Scharfe
2009-09-26 20:39 ` Johannes Schindelin
2009-09-26 20:46 ` Jeff King
2009-09-26 21:03 ` Reece Dunn
2009-09-26 21:12 ` Jeff King
2009-09-26 21:20 ` Reece Dunn
2009-09-26 21:36 ` Jeff King
2009-09-26 21:46 ` Reece Dunn
2009-09-26 21:42 ` Giuseppe Scrivano
2009-09-27 0:41 ` Nicolas Pitre
2009-09-27 8:21 ` Giuseppe Scrivano
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=87ske9cya9.fsf@master.homenet \
--to=gscrivano@gnu.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=srabbelier@gmail.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.