Magellan Linux

Annotation of /trunk/libarchive/patches/libarchive-3.0.4-gcc47.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1821 - (hide annotations) (download)
Wed Jun 27 11:23:12 2012 UTC (11 years, 11 months ago) by niro
File size: 2446 byte(s)
-fixed issues with >= gcc-4.7
1 niro 1821 From 12b0d0d581409733da1931110df8cf540aba34c6 Mon Sep 17 00:00:00 2001
2     From: Dan McGee <dan@archlinux.org>
3     Date: Tue, 27 Mar 2012 17:22:40 -0500
4     Subject: [PATCH] Fixes for GCC 4.7.0
5    
6     Fixes the following compile error exposed with GCC 4.7.0:
7    
8     libarchive/archive_string.c: In function 'cesu8_to_unicode':
9     libarchive/archive_string.c:2450:11: error: 'wc' may be used uninitialized in this function [-Werror=uninitialized]
10     cc1: all warnings being treated as errors
11    
12     As well as a test failure that depends on signed integer wraparound,
13     which is a very bad thing to do in C [1]. Add a bit more magic to ensure
14     the assert is not optimized to always being false. This is still
15     extremely brittle, and a better way should probably be figured out, but
16     this ensures it works as before in all compilers.
17    
18     [1] http://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Signed-Overflow-Examples.html
19     ---
20     libarchive/archive_string.c | 3 ++-
21     libarchive/test/test_read_format_mtree.c | 6 ++++--
22     2 files changed, 6 insertions(+), 3 deletions(-)
23    
24     diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c
25     index 2728a37..2b56a48 100644
26     --- a/libarchive/archive_string.c
27     +++ b/libarchive/archive_string.c
28     @@ -2447,11 +2447,12 @@ combine_surrogate_pair(uint32_t uc, uint32_t uc2)
29     static int
30     cesu8_to_unicode(uint32_t *pwc, const char *s, size_t n)
31     {
32     - uint32_t wc, wc2;
33     + uint32_t wc = 0;
34     int cnt;
35    
36     cnt = _utf8_to_unicode(&wc, s, n);
37     if (cnt == 3 && IS_HIGH_SURROGATE_LA(wc)) {
38     + uint32_t wc2 = 0;
39     if (n - 3 < 3) {
40     /* Invalid byte sequence. */
41     goto invalid_sequence;
42     diff --git a/libarchive/test/test_read_format_mtree.c b/libarchive/test/test_read_format_mtree.c
43     index 0d86bd4..d8df2ea 100644
44     --- a/libarchive/test/test_read_format_mtree.c
45     +++ b/libarchive/test/test_read_format_mtree.c
46     @@ -137,8 +137,10 @@ test_read_format_mtree1(void)
47     /* Verify min_time is the smallest possible time_t. */
48     min_time = archive_entry_mtime(ae);
49     assert(min_time <= 0);
50     - /* Simply asserting min_time - 1 > 0 breaks with some compiler optimizations. */
51     - t = min_time - 1;
52     + /* Simply asserting min_time - 1 > 0 breaks with some compiler
53     + * optimizations. This attempts to do enough to prevent GCC optimizing the
54     + * math completely away and failing the assertion. */
55     + t = (min_time - 1) >> 16;
56     assert(t > 0);
57    
58     /* toooldfile is 1 sec older, which should overflow and get returned
59     --
60     1.7.9.5
61