aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2017-08-22 13:20:55 +0200
committerJay Berkenbilt <ejb@ql.org>2017-08-22 20:13:10 +0200
commitcaf5e39c2e68553101519fb4ce3664a73032d3a3 (patch)
tree232245703f0c15b7ca9fc1e1155f0bab1967d9cd
parent6884ad2eadff6795def2dd336a871227bc8c7d7e (diff)
downloadqpdf-caf5e39c2e68553101519fb4ce3664a73032d3a3.tar.zst
Fix compiler warnings for clang/mac OS X
-rw-r--r--libqpdf/Pl_DCT.cc21
-rw-r--r--libqpdf/Pl_Flate.cc10
-rw-r--r--libqpdf/SecureRandomDataProvider.cc10
-rw-r--r--libqpdf/sph/sph_types.h9
-rw-r--r--libtests/dct_compress.cc6
5 files changed, 31 insertions, 25 deletions
diff --git a/libqpdf/Pl_DCT.cc b/libqpdf/Pl_DCT.cc
index e9ecccd9..68cdc973 100644
--- a/libqpdf/Pl_DCT.cc
+++ b/libqpdf/Pl_DCT.cc
@@ -4,6 +4,7 @@
#include <setjmp.h>
#include <string>
#include <stdexcept>
+#include <cstdlib>
#if BITS_IN_JSAMPLE != 8
# error "qpdf does not support libjpeg built with BITS_IN_JSAMPLE != 8"
@@ -112,17 +113,15 @@ Pl_DCT::compress(void* cinfo_p, PointerHolder<Buffer> b)
struct jpeg_compress_struct* cinfo =
reinterpret_cast<jpeg_compress_struct*>(cinfo_p);
-#ifdef __GNUC__
-# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
+ defined(__clang__))
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wold-style-cast"
-# endif
#endif
jpeg_create_compress(cinfo);
-#ifdef __GNUC__
-# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
+ defined(__clang__))
# pragma GCC diagnostic pop
-# endif
#endif
unsigned char* outbuffer = 0;
unsigned long outsize = 0;
@@ -171,17 +170,15 @@ Pl_DCT::decompress(void* cinfo_p, PointerHolder<Buffer> b)
struct jpeg_decompress_struct* cinfo =
reinterpret_cast<jpeg_decompress_struct*>(cinfo_p);
-#ifdef __GNUC__
-# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
+ defined(__clang__))
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wold-style-cast"
-# endif
#endif
jpeg_create_decompress(cinfo);
-#ifdef __GNUC__
-# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
+ defined(__clang__))
# pragma GCC diagnostic pop
-# endif
#endif
jpeg_mem_src(cinfo, b->getBuffer(), b->getSize());
diff --git a/libqpdf/Pl_Flate.cc b/libqpdf/Pl_Flate.cc
index 535383c9..ce4c9ed1 100644
--- a/libqpdf/Pl_Flate.cc
+++ b/libqpdf/Pl_Flate.cc
@@ -76,11 +76,10 @@ Pl_Flate::handleData(unsigned char* data, int len, int flush)
// deflateInit and inflateInit are macros that use old-style
// casts.
-#ifdef __GNUC__
-# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
+ defined(__clang__))
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wold-style-cast"
-# endif
#endif
if (this->action == a_deflate)
{
@@ -90,10 +89,9 @@ Pl_Flate::handleData(unsigned char* data, int len, int flush)
{
err = inflateInit(&zstream);
}
-#ifdef __GNUC__
-# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
+ defined(__clang__))
# pragma GCC diagnostic pop
-# endif
#endif
checkError("Init", err);
diff --git a/libqpdf/SecureRandomDataProvider.cc b/libqpdf/SecureRandomDataProvider.cc
index ca891036..1720b875 100644
--- a/libqpdf/SecureRandomDataProvider.cc
+++ b/libqpdf/SecureRandomDataProvider.cc
@@ -48,18 +48,16 @@ class WindowsCryptProvider
PROV_RSA_FULL,
0))
{
-#ifdef __GNUC__
-# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
+ defined(__clang__))
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wold-style-cast"
# pragma GCC diagnostic ignored "-Wsign-compare"
-# endif
#endif
if (GetLastError() == NTE_BAD_KEYSET)
-#ifdef __GNUC__
-# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
+ defined(__clang__))
# pragma GCC diagnostic pop
-# endif
#endif
{
if (! CryptAcquireContext(&crypt_prov,
diff --git a/libqpdf/sph/sph_types.h b/libqpdf/sph/sph_types.h
index 7295b0b3..eab09a26 100644
--- a/libqpdf/sph/sph_types.h
+++ b/libqpdf/sph/sph_types.h
@@ -804,6 +804,11 @@ static inline void sph_enc64be_aligned(void *dst, sph_u64 val);
/* ============== END documentation block for Doxygen ============= */
+#if defined(__clang__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wold-style-cast"
+#endif
+
#ifndef DOXYGEN_IGNORE
/*
@@ -1971,6 +1976,10 @@ sph_dec64le_aligned(const void *src)
#endif
+#if defined(__clang__)
+# pragma GCC diagnostic pop
+#endif
+
#endif /* Doxygen excluded block */
#endif
diff --git a/libtests/dct_compress.cc b/libtests/dct_compress.cc
index ea5d9c33..e2ed7adf 100644
--- a/libtests/dct_compress.cc
+++ b/libtests/dct_compress.cc
@@ -17,11 +17,15 @@ static void usage()
class Callback: public Pl_DCT::CompressConfig
{
public:
+ Callback() :
+ called(false)
+ {
+ }
virtual ~Callback()
{
}
virtual void apply(jpeg_compress_struct*);
- bool called = false;
+ bool called;
};
void Callback::apply(jpeg_compress_struct*)