Fixes the following compile error exposed with GCC 4.7.0:
libarchive/archive_string.c: In function 'cesu8_to_unicode':
libarchive/archive_string.c:2450:11: error: 'wc' may be used uninitialized in this function [-Werror=uninitialized]
cc1: all warnings being treated as errors
As well as a test failure that depends on signed integer wraparound,
which is a very bad thing to do in C [1]. Mark the intermediate result
as volatile to prevent the compiler optimizing away the arithmetic and
the logical test.
[1] http://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Signed-Overflow-Examples.html
static int
cesu8_to_unicode(uint32_t *pwc, const char *s, size_t n)
{
- uint32_t wc, wc2;
+ uint32_t wc = 0;
int cnt;
cnt = _utf8_to_unicode(&wc, s, n);
if (cnt == 3 && IS_HIGH_SURROGATE_LA(wc)) {
+ uint32_t wc2 = 0;
if (n - 3 < 3) {
/* Invalid byte sequence. */
goto invalid_sequence;
* without relying on overflow. This assumes that long long
* is at least 64 bits. */
static const long long max_int64 = ((((long long)1) << 62) - 1) + (((long long)1) << 62);
- time_t min_time, t;
+ time_t min_time;
+ volatile time_t t;
extract_reference_file(reffile);