File libarchive-fix-checks.patch of Package libarchive

From da8ac32da9e5ee4a27674de4442e24c26cb2aa6a Mon Sep 17 00:00:00 2001
From: Dan McGee <dan@archlinux.org>
Date: Tue, 27 Mar 2012 17:22:40 -0500
Subject: [PATCH] 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
---
 libarchive/archive_string.c              |    3 ++-
 libarchive/test/test_read_format_mtree.c |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c
index 2728a37..2b56a48 100644
--- a/libarchive/archive_string.c
+++ b/libarchive/archive_string.c
@@ -2447,11 +2447,12 @@ struct archive_string_conv *
 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 0d86bd4..a5d7feb 100644
--- a/libarchive/test/test_read_format_mtree.c
+++ b/libarchive/test/test_read_format_mtree.c
@@ -37,7 +37,8 @@
 	 * 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);
 
-- 
1.7.10
openSUSE Build Service is sponsored by