Commit caf5e39c2e68553101519fb4ce3664a73032d3a3

Authored by Jay Berkenbilt
1 parent 6884ad2e

Fix compiler warnings for clang/mac OS X

libqpdf/Pl_DCT.cc
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 #include <setjmp.h> 4 #include <setjmp.h>
5 #include <string> 5 #include <string>
6 #include <stdexcept> 6 #include <stdexcept>
  7 +#include <cstdlib>
7 8
8 #if BITS_IN_JSAMPLE != 8 9 #if BITS_IN_JSAMPLE != 8
9 # error "qpdf does not support libjpeg built with BITS_IN_JSAMPLE != 8" 10 # error "qpdf does not support libjpeg built with BITS_IN_JSAMPLE != 8"
@@ -112,17 +113,15 @@ Pl_DCT::compress(void* cinfo_p, PointerHolder&lt;Buffer&gt; b) @@ -112,17 +113,15 @@ Pl_DCT::compress(void* cinfo_p, PointerHolder&lt;Buffer&gt; b)
112 struct jpeg_compress_struct* cinfo = 113 struct jpeg_compress_struct* cinfo =
113 reinterpret_cast<jpeg_compress_struct*>(cinfo_p); 114 reinterpret_cast<jpeg_compress_struct*>(cinfo_p);
114 115
115 -#ifdef __GNUC__  
116 -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 116 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
  117 + defined(__clang__))
117 # pragma GCC diagnostic push 118 # pragma GCC diagnostic push
118 # pragma GCC diagnostic ignored "-Wold-style-cast" 119 # pragma GCC diagnostic ignored "-Wold-style-cast"
119 -# endif  
120 #endif 120 #endif
121 jpeg_create_compress(cinfo); 121 jpeg_create_compress(cinfo);
122 -#ifdef __GNUC__  
123 -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 122 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
  123 + defined(__clang__))
124 # pragma GCC diagnostic pop 124 # pragma GCC diagnostic pop
125 -# endif  
126 #endif 125 #endif
127 unsigned char* outbuffer = 0; 126 unsigned char* outbuffer = 0;
128 unsigned long outsize = 0; 127 unsigned long outsize = 0;
@@ -171,17 +170,15 @@ Pl_DCT::decompress(void* cinfo_p, PointerHolder&lt;Buffer&gt; b) @@ -171,17 +170,15 @@ Pl_DCT::decompress(void* cinfo_p, PointerHolder&lt;Buffer&gt; b)
171 struct jpeg_decompress_struct* cinfo = 170 struct jpeg_decompress_struct* cinfo =
172 reinterpret_cast<jpeg_decompress_struct*>(cinfo_p); 171 reinterpret_cast<jpeg_decompress_struct*>(cinfo_p);
173 172
174 -#ifdef __GNUC__  
175 -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 173 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
  174 + defined(__clang__))
176 # pragma GCC diagnostic push 175 # pragma GCC diagnostic push
177 # pragma GCC diagnostic ignored "-Wold-style-cast" 176 # pragma GCC diagnostic ignored "-Wold-style-cast"
178 -# endif  
179 #endif 177 #endif
180 jpeg_create_decompress(cinfo); 178 jpeg_create_decompress(cinfo);
181 -#ifdef __GNUC__  
182 -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 179 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
  180 + defined(__clang__))
183 # pragma GCC diagnostic pop 181 # pragma GCC diagnostic pop
184 -# endif  
185 #endif 182 #endif
186 jpeg_mem_src(cinfo, b->getBuffer(), b->getSize()); 183 jpeg_mem_src(cinfo, b->getBuffer(), b->getSize());
187 184
libqpdf/Pl_Flate.cc
@@ -76,11 +76,10 @@ Pl_Flate::handleData(unsigned char* data, int len, int flush) @@ -76,11 +76,10 @@ Pl_Flate::handleData(unsigned char* data, int len, int flush)
76 76
77 // deflateInit and inflateInit are macros that use old-style 77 // deflateInit and inflateInit are macros that use old-style
78 // casts. 78 // casts.
79 -#ifdef __GNUC__  
80 -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 79 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
  80 + defined(__clang__))
81 # pragma GCC diagnostic push 81 # pragma GCC diagnostic push
82 # pragma GCC diagnostic ignored "-Wold-style-cast" 82 # pragma GCC diagnostic ignored "-Wold-style-cast"
83 -# endif  
84 #endif 83 #endif
85 if (this->action == a_deflate) 84 if (this->action == a_deflate)
86 { 85 {
@@ -90,10 +89,9 @@ Pl_Flate::handleData(unsigned char* data, int len, int flush) @@ -90,10 +89,9 @@ Pl_Flate::handleData(unsigned char* data, int len, int flush)
90 { 89 {
91 err = inflateInit(&zstream); 90 err = inflateInit(&zstream);
92 } 91 }
93 -#ifdef __GNUC__  
94 -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 92 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
  93 + defined(__clang__))
95 # pragma GCC diagnostic pop 94 # pragma GCC diagnostic pop
96 -# endif  
97 #endif 95 #endif
98 96
99 checkError("Init", err); 97 checkError("Init", err);
libqpdf/SecureRandomDataProvider.cc
@@ -48,18 +48,16 @@ class WindowsCryptProvider @@ -48,18 +48,16 @@ class WindowsCryptProvider
48 PROV_RSA_FULL, 48 PROV_RSA_FULL,
49 0)) 49 0))
50 { 50 {
51 -#ifdef __GNUC__  
52 -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 51 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
  52 + defined(__clang__))
53 # pragma GCC diagnostic push 53 # pragma GCC diagnostic push
54 # pragma GCC diagnostic ignored "-Wold-style-cast" 54 # pragma GCC diagnostic ignored "-Wold-style-cast"
55 # pragma GCC diagnostic ignored "-Wsign-compare" 55 # pragma GCC diagnostic ignored "-Wsign-compare"
56 -# endif  
57 #endif 56 #endif
58 if (GetLastError() == NTE_BAD_KEYSET) 57 if (GetLastError() == NTE_BAD_KEYSET)
59 -#ifdef __GNUC__  
60 -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 58 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
  59 + defined(__clang__))
61 # pragma GCC diagnostic pop 60 # pragma GCC diagnostic pop
62 -# endif  
63 #endif 61 #endif
64 { 62 {
65 if (! CryptAcquireContext(&crypt_prov, 63 if (! CryptAcquireContext(&crypt_prov,
libqpdf/sph/sph_types.h
@@ -804,6 +804,11 @@ static inline void sph_enc64be_aligned(void *dst, sph_u64 val); @@ -804,6 +804,11 @@ static inline void sph_enc64be_aligned(void *dst, sph_u64 val);
804 804
805 /* ============== END documentation block for Doxygen ============= */ 805 /* ============== END documentation block for Doxygen ============= */
806 806
  807 +#if defined(__clang__)
  808 +# pragma GCC diagnostic push
  809 +# pragma GCC diagnostic ignored "-Wold-style-cast"
  810 +#endif
  811 +
807 #ifndef DOXYGEN_IGNORE 812 #ifndef DOXYGEN_IGNORE
808 813
809 /* 814 /*
@@ -1971,6 +1976,10 @@ sph_dec64le_aligned(const void *src) @@ -1971,6 +1976,10 @@ sph_dec64le_aligned(const void *src)
1971 1976
1972 #endif 1977 #endif
1973 1978
  1979 +#if defined(__clang__)
  1980 +# pragma GCC diagnostic pop
  1981 +#endif
  1982 +
1974 #endif /* Doxygen excluded block */ 1983 #endif /* Doxygen excluded block */
1975 1984
1976 #endif 1985 #endif
libtests/dct_compress.cc
@@ -17,11 +17,15 @@ static void usage() @@ -17,11 +17,15 @@ static void usage()
17 class Callback: public Pl_DCT::CompressConfig 17 class Callback: public Pl_DCT::CompressConfig
18 { 18 {
19 public: 19 public:
  20 + Callback() :
  21 + called(false)
  22 + {
  23 + }
20 virtual ~Callback() 24 virtual ~Callback()
21 { 25 {
22 } 26 }
23 virtual void apply(jpeg_compress_struct*); 27 virtual void apply(jpeg_compress_struct*);
24 - bool called = false; 28 + bool called;
25 }; 29 };
26 30
27 void Callback::apply(jpeg_compress_struct*) 31 void Callback::apply(jpeg_compress_struct*)