git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* PATCH 1/2] -Wuninitialized: remove some 'init-self' workarounds
@ 2018-03-19 17:54 Ramsay Jones
  2018-03-20  1:33 ` Ramsay Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Ramsay Jones @ 2018-03-19 17:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, Johannes Schindelin, GIT Mailing-list


The 'self-initialised' variables construct (ie <type> var = var;) has
been used to silence gcc '-W[maybe-]uninitialized' warnings. This has,
unfortunately, caused MSVC to issue 'uninitialized variable' warnings.
Also, using clang static analysis causes complaints about an 'Assigned
value is garbage or undefined'.

There are six such constructs in the current codebase. Only one of the
six causes gcc to issue a '-Wmaybe-uninitialized' warning (which will
be addressed elsewhere). The remaining five 'init-self' gcc workarounds
are noted below, along with the commit which introduced them:

  1. builtin/rev-list.c: 'reaches' and 'all', see commit 457f08a030
     ("git-rev-list: add --bisect-vars option.", 2007-03-21).

  2. merge-recursive.c:2064 'mrtree', see commit f120ae2a8e ("merge-
     recursive.c: mrtree in merge() is not used before set", 2007-10-29).

  3. fast-import.c:3023 'oe', see commit 85c62395b1 ("fast-import: let
     importers retrieve blobs", 2010-11-28).

  4. fast-import.c:3006 'oe', see commit 28c7b1f7b7 ("fast-import: add a
     get-mark command", 2015-07-01).

Remove the 'self-initialised' variable constructs noted above.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
 builtin/rev-list.c | 2 +-
 fast-import.c      | 4 ++--
 merge-recursive.c  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index d5345b6a2..fbfc62de4 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -479,7 +479,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 		mark_edges_uninteresting(&revs, show_edge);
 
 	if (bisect_list) {
-		int reaches = reaches, all = all;
+		int reaches, all;
 
 		find_bisection(&revs.commits, &reaches, &all, bisect_find_all);
 
diff --git a/fast-import.c b/fast-import.c
index b70ac025e..1f01a2205 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -3003,7 +3003,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
 
 static void parse_get_mark(const char *p)
 {
-	struct object_entry *oe = oe;
+	struct object_entry *oe;
 	char output[GIT_MAX_HEXSZ + 2];
 
 	/* get-mark SP <object> LF */
@@ -3020,7 +3020,7 @@ static void parse_get_mark(const char *p)
 
 static void parse_cat_blob(const char *p)
 {
-	struct object_entry *oe = oe;
+	struct object_entry *oe;
 	struct object_id oid;
 
 	/* cat-blob SP <object> LF */
diff --git a/merge-recursive.c b/merge-recursive.c
index 0fc580d8c..fa9067eec 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2061,7 +2061,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)) {
-- 
2.16.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: PATCH 1/2] -Wuninitialized: remove some 'init-self' workarounds
  2018-03-19 17:54 PATCH 1/2] -Wuninitialized: remove some 'init-self' workarounds Ramsay Jones
@ 2018-03-20  1:33 ` Ramsay Jones
  2018-03-20 16:59   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Ramsay Jones @ 2018-03-20  1:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, Johannes Schindelin, GIT Mailing-list



On 19/03/18 17:54, Ramsay Jones wrote:
> 
> The 'self-initialised' variables construct (ie <type> var = var;) has
> been used to silence gcc '-W[maybe-]uninitialized' warnings. This has,
> unfortunately, caused MSVC to issue 'uninitialized variable' warnings.
> Also, using clang static analysis causes complaints about an 'Assigned
> value is garbage or undefined'.
> 
[snip]

Hi Junio,

You may not have noticed that I messed up the Subject line of
this patch - I managed to drop the '[' character in the patch
prefix string. :(

So, the commit 7bc195d877 on the 'pu' branch is titled:

  "PATCH 1/2] -Wininitialized: remove some 'init-self' workarounds"

Ahem! Sorry about that.

ATB,
Ramsay Jones



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH 1/2] -Wuninitialized: remove some 'init-self' workarounds
  2018-03-20  1:33 ` Ramsay Jones
@ 2018-03-20 16:59   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2018-03-20 16:59 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: Jeff King, Johannes Schindelin, GIT Mailing-list

Ramsay Jones <ramsay@ramsayjones.plus.com> writes:

> You may not have noticed that I messed up the Subject line of
> this patch - I managed to drop the '[' character in the patch
> prefix string. :(

I did notice the lack of '[' while reading, and then totally forgot
by the time I started queuing various topics.

Thanks for reminding.

> So, the commit 7bc195d877 on the 'pu' branch is titled:
>
>   "PATCH 1/2] -Wininitialized: remove some 'init-self' workarounds"
>
> Ahem! Sorry about that.
>
> ATB,
> Ramsay Jones

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-20 16:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 17:54 PATCH 1/2] -Wuninitialized: remove some 'init-self' workarounds Ramsay Jones
2018-03-20  1:33 ` Ramsay Jones
2018-03-20 16:59   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).