Skip to content

Commit 156e178

Browse files
ramsay-jonesgitster
authored andcommitted
-Wuninitialized: remove some 'init-self' workarounds
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 457f08a ("git-rev-list: add --bisect-vars option.", 2007-03-21). 2. merge-recursive.c:2064 'mrtree', see commit f120ae2 ("merge- recursive.c: mrtree in merge() is not used before set", 2007-10-29). 3. fast-import.c:3023 'oe', see commit 85c6239 ("fast-import: let importers retrieve blobs", 2010-11-28). 4. fast-import.c:3006 'oe', see commit 28c7b1f ("fast-import: add a get-mark command", 2015-07-01). Remove the 'self-initialised' variable constructs noted above. Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 38e79b1 commit 156e178

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

builtin/rev-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
479479
mark_edges_uninteresting(&revs, show_edge);
480480

481481
if (bisect_list) {
482-
int reaches = reaches, all = all;
482+
int reaches, all;
483483

484484
find_bisection(&revs.commits, &reaches, &all, bisect_find_all);
485485

fast-import.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,7 +3003,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
30033003

30043004
static void parse_get_mark(const char *p)
30053005
{
3006-
struct object_entry *oe = oe;
3006+
struct object_entry *oe;
30073007
char output[GIT_MAX_HEXSZ + 2];
30083008

30093009
/* get-mark SP <object> LF */
@@ -3020,7 +3020,7 @@ static void parse_get_mark(const char *p)
30203020

30213021
static void parse_cat_blob(const char *p)
30223022
{
3023-
struct object_entry *oe = oe;
3023+
struct object_entry *oe;
30243024
struct object_id oid;
30253025

30263026
/* cat-blob SP <object> LF */

merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2070,7 +2070,7 @@ int merge_recursive(struct merge_options *o,
20702070
{
20712071
struct commit_list *iter;
20722072
struct commit *merged_common_ancestors;
2073-
struct tree *mrtree = mrtree;
2073+
struct tree *mrtree;
20742074
int clean;
20752075

20762076
if (show(o, 4)) {

0 commit comments

Comments
 (0)