From: Dan McGee Date: Tue, 27 Mar 2012 22:22:40 +0000 (-0500) Subject: Fixes for GCC 4.7.0 X-Git-Tag: v3.1.0~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da8ac32da9e5ee4a27674de4442e24c26cb2aa6a;p=thirdparty%2Flibarchive.git Fixes for GCC 4.7.0 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 --- diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c index 2728a376c..2b56a48ee 100644 --- a/libarchive/archive_string.c +++ b/libarchive/archive_string.c @@ -2447,11 +2447,12 @@ combine_surrogate_pair(uint32_t uc, uint32_t uc2) 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; diff --git a/libarchive/test/test_read_format_mtree.c b/libarchive/test/test_read_format_mtree.c index 0d86bd478..a5d7febe1 100644 --- a/libarchive/test/test_read_format_mtree.c +++ b/libarchive/test/test_read_format_mtree.c @@ -37,7 +37,8 @@ test_read_format_mtree1(void) * 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);