vcs-svn: avoid self-assignment in dummy initialization of pre_off
commite654f7e8af72a34a3a93ca8786d972eff205e4ab
authorDavid Barr <davidbarr@google.com>
Thu, 31 May 2012 14:41:25 +0000 (1 00:41 +1000)
committerJonathan Nieder <jrnieder@gmail.com>
Fri, 6 Jul 2012 04:26:52 +0000 (5 23:26 -0500)
tree23e0908fd0e3a5f94ec055453acae34a6a8007a3
parenta0f14848335f811aa84b83439c96c394b68cca05
vcs-svn: avoid self-assignment in dummy initialization of pre_off

Without this change, clang complains:

 vcs-svn/svndiff.c:298:3: warning: Assigned value is garbage or undefined
                 off_t pre_off = pre_off; /* stupid GCC... */
                 ^               ~~~~~~~

This code uses an old and common idiom for suppressing an
"uninitialized variable" warning, and clang is wrong to warn about it.
The idiom tells the compiler to leave the variable uninitialized,
which saves a few bytes of code size, and, more importantly, allows
valgrind to check at runtime that the variable is properly initialized
by the time it is used.

But MSVC and clang do not know that idiom, so let's avoid it in
vcs-svn/ code.

Initialize pre_off to -1, a recognizably meaningless value, to allow
future code changes that cause pre_off to be used before it is
initialized to be caught early.

Signed-off-by: David Barr <davidbarr@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
svndiff.c