From: Jonathan Nieder <jrnieder@gmail.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning
Date: Wed, 16 Mar 2011 05:57:09 -0500 [thread overview]
Message-ID: <20110316105709.GC8277@elie> (raw)
In-Reply-To: <4D8088C1.5050901@viscovery.net>
Johannes Sixt wrote:
> I don't think so. This is not a special warning, but just
>
> warning C4700: uninitialized local variable 'expire' used
>
> That is, if you disable it, you also disable it for locations where the
> warning would be justified. That's not something that I would like to do.
Right. Below is a patch to play with which gets rid of the
'expire = expire' style suppressions.
It was produced with
spatch -sp_file self-assignment.cocci $(git ls-files -- '*.c' '*.h')
where self-assignment.cocci is
@@
identifier x;
type T;
@@
- T x = x;
+ T x;
but required some pre- and post-processing to work around coccinelle
bugs. :/
---
builtin/cat-file.c | 2 +-
builtin/fast-export.c | 2 +-
builtin/rev-list.c | 2 +-
contrib/examples/builtin-fetch--tool.c | 4 ++--
fast-import.c | 8 ++++----
match-trees.c | 12 ++++++------
merge-recursive.c | 2 +-
run-command.c | 2 +-
submodule.c | 2 +-
transport.c | 2 +-
wt-status.c | 2 +-
11 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 94632db..31cb172 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -168,7 +168,7 @@ static int batch_one_object(const char *obj_name, int print_contents)
unsigned char sha1[20];
enum object_type type = 0;
unsigned long size;
- void *contents = contents;
+ void *contents;
if (!obj_name)
return 1;
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index daf1945..408156e 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -463,7 +463,7 @@ static void get_tags_and_duplicates(struct object_array *pending,
for (i = 0; i < pending->nr; i++) {
struct object_array_entry *e = pending->objects + i;
unsigned char sha1[20];
- struct commit *commit = commit;
+ struct commit *commit;
char *full_name;
if (dwim_ref(e->name, strlen(e->name), sha1, &full_name) != 1)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index ba27d39..96d10b0 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -397,7 +397,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
mark_edges_uninteresting(revs.commits, &revs, show_edge);
if (bisect_list) {
- int reaches = reaches, all = all;
+ int reaches, all;
revs.commits = find_bisection(revs.commits, &reaches, &all,
bisect_find_all);
diff --git a/contrib/examples/builtin-fetch--tool.c b/contrib/examples/builtin-fetch--tool.c
index 3140e40..c5bd034 100644
--- a/contrib/examples/builtin-fetch--tool.c
+++ b/contrib/examples/builtin-fetch--tool.c
@@ -416,14 +416,14 @@ static int expand_refs_wildcard(const char *ls_remote_result, int numrefs,
static int pick_rref(int sha1_only, const char *rref, const char *ls_remote_result)
{
int err = 0;
- int lrr_count = lrr_count, i, pass;
+ int lrr_count, i, pass;
const char *cp;
struct lrr {
const char *line;
const char *name;
int namelen;
int shown;
- } *lrr_list = lrr_list;
+ } *lrr_list;
for (pass = 0; pass < 2; pass++) {
/* pass 0 counts and allocates, pass 1 fills... */
diff --git a/fast-import.c b/fast-import.c
index e24ee2c..565d895 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2196,7 +2196,7 @@ static void file_change_m(struct branch *b)
const char *p = command_buf.buf + 2;
static struct strbuf uq = STRBUF_INIT;
const char *endp;
- struct object_entry *oe = oe;
+ struct object_entry *oe;
unsigned char sha1[20];
uint16_t mode, inline_data = 0;
@@ -2365,7 +2365,7 @@ static void note_change_n(struct branch *b, unsigned char old_fanout)
{
const char *p = command_buf.buf + 2;
static struct strbuf uq = STRBUF_INIT;
- struct object_entry *oe = oe;
+ struct object_entry *oe;
struct branch *s;
unsigned char sha1[20], commit_sha1[20];
char path[60];
@@ -2525,7 +2525,7 @@ static int parse_from(struct branch *b)
static struct hash_list *parse_merge(unsigned int *count)
{
- struct hash_list *list = NULL, *n, *e = e;
+ struct hash_list *list = NULL, *n, *e;
const char *from;
struct branch *s;
@@ -2819,7 +2819,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20])
static void parse_cat_blob(void)
{
const char *p;
- struct object_entry *oe = oe;
+ struct object_entry *oe;
unsigned char sha1[20];
/* cat-blob SP <object> LF */
diff --git a/match-trees.c b/match-trees.c
index 26f7ed1..9cfcc8b 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -72,12 +72,12 @@ static int score_trees(const unsigned char *hash1, const unsigned char *hash2)
die("%s is not a tree", sha1_to_hex(hash2));
init_tree_desc(&two, two_buf, size);
while (one.size | two.size) {
- const unsigned char *elem1 = elem1;
- const unsigned char *elem2 = elem2;
- const char *path1 = path1;
- const char *path2 = path2;
- unsigned mode1 = mode1;
- unsigned mode2 = mode2;
+ const unsigned char *elem1;
+ const unsigned char *elem2;
+ const char *path1;
+ const char *path2;
+ unsigned mode1;
+ unsigned mode2;
int cmp;
if (one.size)
diff --git a/merge-recursive.c b/merge-recursive.c
index 2a4f739..8ed0f29 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1583,7 +1583,7 @@ int merge_recursive(struct merge_options *o,
{
struct commit_list *iter;
struct commit *merged_common_ancestors;
- struct tree *mrtree = mrtree;
+ struct tree *mrtree;
int clean;
if (show(o, 4)) {
diff --git a/run-command.c b/run-command.c
index f91e446..f4fb936 100644
--- a/run-command.c
+++ b/run-command.c
@@ -139,7 +139,7 @@ int start_command(struct child_process *cmd)
{
int need_in, need_out, need_err;
int fdin[2], fdout[2], fderr[2];
- int failed_errno = failed_errno;
+ int failed_errno;
/*
* In case of errors we must keep the promise to close FDs
diff --git a/submodule.c b/submodule.c
index 6f1c107..dcbb2d3 100644
--- a/submodule.c
+++ b/submodule.c
@@ -158,7 +158,7 @@ void show_submodule_summary(FILE *f, const char *path,
const char *del, const char *add, const char *reset)
{
struct rev_info rev;
- struct commit *commit, *left = left, *right = right;
+ struct commit *commit, *left, *right;
struct commit_list *merge_bases, *list;
const char *message = NULL;
struct strbuf sb = STRBUF_INIT;
diff --git a/transport.c b/transport.c
index 0078660..718605f 100644
--- a/transport.c
+++ b/transport.c
@@ -104,7 +104,7 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
return;
for (;;) {
- int cmp = cmp, len;
+ int cmp, len;
if (!fgets(buffer, sizeof(buffer), f)) {
fclose(f);
diff --git a/wt-status.c b/wt-status.c
index 4daa8bb..3298897 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -153,7 +153,7 @@ static void wt_status_print_change_data(struct wt_status *s,
{
struct wt_status_change_data *d = it->util;
const char *c = color(change_type, s);
- int status = status;
+ int status;
char *one_name;
char *two_name;
const char *one, *two;
--
1.7.4.1
next prev parent reply other threads:[~2011-03-16 10:57 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-16 2:49 [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning Jonathan Nieder
2011-03-16 3:42 ` [PATCH nd/struct-pathspec] declare 1-bit bitfields to be unsigned Jonathan Nieder
2011-03-16 5:38 ` Junio C Hamano
2011-03-16 14:20 ` Nguyen Thai Ngoc Duy
2011-03-16 5:22 ` [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning Junio C Hamano
2011-03-16 6:28 ` Jonathan Nieder
2011-03-16 9:09 ` Johannes Sixt
2011-03-16 9:47 ` Jonathan Nieder
2011-03-16 9:54 ` Johannes Sixt
2011-03-16 10:57 ` Jonathan Nieder [this message]
2011-03-16 11:35 ` [RFC/PATCH 0/6] silence -Wuninitialized warnings that previously used the a = a trick Jonathan Nieder
2011-03-16 11:36 ` [PATCH 1/6] match-trees: kill off remaining -Wuninitialized warning Jonathan Nieder
2011-03-16 11:36 ` [PATCH 2/6] run-command: initialize failed_errno to 0 Jonathan Nieder
2011-03-16 11:37 ` [PATCH 3/6] diff --submodule: suppress -Wuninitialized warning by initializing to NULL Jonathan Nieder
2011-03-16 11:37 ` [PATCH 4/6] rsync transport: clarify insert_packed_refs Jonathan Nieder
2011-03-16 11:37 ` [PATCH 5/6] wt-status: protect against invalid change_type Jonathan Nieder
2011-03-16 11:38 ` [PATCH 6/6] fast-import: suppress -Wuninitialized warning by initializing to NULL Jonathan Nieder
2011-03-16 6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
2011-03-16 6:59 ` [PATCH 1/8] enums: omit trailing comma for portability Jonathan Nieder
2011-03-16 7:00 ` [PATCH 2/8] compat: make gcc bswap an inline function Jonathan Nieder
2011-03-16 9:21 ` Johannes Sixt
2011-03-16 9:31 ` Jonathan Nieder
2011-03-16 19:44 ` Junio C Hamano
2011-03-16 7:01 ` [PATCH 3/8] svn-fe: do not use "return" for tail call returning void Jonathan Nieder
2011-03-16 7:02 ` [PATCH 4/8] vcs-svn: remove spurious semicolons Jonathan Nieder
2011-03-16 19:47 ` Junio C Hamano
2011-03-16 20:03 ` Jonathan Nieder
2011-03-16 7:08 ` [PATCH 5/8] standardize brace placement in struct definitions Jonathan Nieder
2011-03-18 7:25 ` Junio C Hamano
2011-03-16 7:10 ` [PATCH 6/8] branch: split off function that writes tracking info and commit subject Jonathan Nieder
2011-03-16 7:12 ` [PATCH 7/8] cherry: split off function to print output lines Jonathan Nieder
2011-03-16 7:14 ` [PATCH 8/8] diff --submodule: split into bite-sized pieces Jonathan Nieder
2011-03-16 18:43 ` Jens Lehmann
2011-03-16 19:33 ` Jonathan Nieder
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=20110316105709.GC8277@elie \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j.sixt@viscovery.net \
--cc=peff@peff.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).