Re: [PATCH 3/4] drop some obsolete x = x compiler warning hacks

2013-03-24 Thread Torsten Bögershausen
On 21.03.13 21:47, Jonathan Nieder wrote:
 Jeff King wrote:
 
 And 4.3 was old enough for me to say I do not care if you can run with
 -Wall -Werror or not, let alone 4.2.
 
 Changes like this can only reveal bugs (in git or optimizers) that
 were hidden before, without regressing actual runtime behavior, so for
 what it's worth I like them.
 
 I think perhaps we should encourage people to use
 -Wno-error=uninitialized, in addition to cleaning up our code where
 reasonably recent optimizers reveal it to be confusing.
 
 Reviewed-by: Jonathan Nieder jrnie...@gmail.com

I got 2 warnings, but reading the comments I feel that

Mac OS 10.6 and i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 
5666) (dot 3)

is outdated ;-)


builtin/cat-file.c: In function ~cmd_cat_file~:
builtin/cat-file.c:196: warning: ~contents~ may be used uninitialized in this 
function
builtin/cat-file.c:196: note: ~contents~ was declared here


fast-import.c: In function ‘parse_new_commit’:
fast-import.c:2438: warning: ‘oe’ may be used uninitialized in this function
fast-import.c:2438: note: ‘oe’ was declared here

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] drop some obsolete x = x compiler warning hacks

2013-03-21 Thread Jeff King
In cases where the setting and access of a variable are
protected by the same conditional flag, older versions of
gcc would generate a might be used unitialized warning. We
silence the warning by initializing the variable to itself,
a hack that gcc recognizes.

Modern versions of gcc are smart enough to get this right,
going back to at least version 4.3.5. gcc 4.1 does get it
wrong in both cases, but is sufficiently old that we
probably don't need to care about it anymore.

Signed-off-by: Jeff King p...@peff.net
---
gcc 4.2 is conspicuously missing because no current Debian system even
has a backwards-compatibility package for it, making it harder to test.
And 4.3 was old enough for me to say I do not care if you can run with
-Wall -Werror or not, let alone 4.2.

 builtin/cat-file.c | 2 +-
 fast-import.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 00528dd..ad29000 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -193,7 +193,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/fast-import.c b/fast-import.c
index 583a439..e12a8b8 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2434,7 +2434,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];
-- 
1.8.2.rc2.8.g2161951

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] drop some obsolete x = x compiler warning hacks

2013-03-21 Thread Erik Faye-Lund
On Thu, Mar 21, 2013 at 12:10 PM, Jeff King p...@peff.net wrote:
 In cases where the setting and access of a variable are
 protected by the same conditional flag, older versions of
 gcc would generate a might be used unitialized warning. We
 silence the warning by initializing the variable to itself,
 a hack that gcc recognizes.

 Modern versions of gcc are smart enough to get this right,
 going back to at least version 4.3.5. gcc 4.1 does get it
 wrong in both cases, but is sufficiently old that we
 probably don't need to care about it anymore.

 Signed-off-by: Jeff King p...@peff.net
 ---
 gcc 4.2 is conspicuously missing because no current Debian system even
 has a backwards-compatibility package for it, making it harder to test.
 And 4.3 was old enough for me to say I do not care if you can run with
 -Wall -Werror or not, let alone 4.2.

Just a data-point. This is the version we use in msysGit:

$ gcc --version
gcc.exe (TDM-1 mingw32) 4.4.0

So yeah, it's not going to increase false positives here, I guess.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] drop some obsolete x = x compiler warning hacks

2013-03-21 Thread Jonathan Nieder
Jeff King wrote:

 And 4.3 was old enough for me to say I do not care if you can run with
 -Wall -Werror or not, let alone 4.2.

Changes like this can only reveal bugs (in git or optimizers) that
were hidden before, without regressing actual runtime behavior, so for
what it's worth I like them.

I think perhaps we should encourage people to use
-Wno-error=uninitialized, in addition to cleaning up our code where
reasonably recent optimizers reveal it to be confusing.

Reviewed-by: Jonathan Nieder jrnie...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html