From 624911e48174094c80df7e27b28cc2b2d46f4398 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 15 Aug 2012 19:25:44 +0200 Subject: [PATCH] Fix -Wclobbered warnings GCC warns: warning: argument 'x' might be clobbered by 'longjmp' or 'vfork' [-Wclobbered] Apparently, the real fix would be annotating the functions correctly with noreturn and returns_twice attributes, but there's also workarounds for these, at least in the png case, so adding volatile was the easier way out here. Needed a cast to lose the volatile again, passing the argument to qMin(). Change-Id: Id820cf9b65752359f3b8f268172ba71bc9a76784 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thiago Macieira --- src/gui/image/qjpeghandler.cpp | 6 +++--- src/gui/image/qpnghandler.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp index 057bfc2592..647ef6bad4 100644 --- a/src/gui/image/qjpeghandler.cpp +++ b/src/gui/image/qjpeghandler.cpp @@ -277,7 +277,7 @@ static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info, static bool read_jpeg_image(QImage *outImage, QSize scaledSize, QRect scaledClipRect, - QRect clipRect, int inQuality, j_decompress_ptr info, struct my_error_mgr* err ) + QRect clipRect, volatile int inQuality, j_decompress_ptr info, struct my_error_mgr* err ) { if (!setjmp(err->setjmp_buffer)) { // -1 means default quality. @@ -561,7 +561,7 @@ static inline void set_text(const QImage &image, j_compress_ptr cinfo, const QSt } } -static bool write_jpeg_image(const QImage &image, QIODevice *device, int sourceQuality, const QString &description) +static bool write_jpeg_image(const QImage &image, QIODevice *device, volatile int sourceQuality, const QString &description) { bool success = false; const QVector cmap = image.colorTable(); @@ -624,7 +624,7 @@ static bool write_jpeg_image(const QImage &image, QIODevice *device, int sourceQ } - int quality = sourceQuality >= 0 ? qMin(sourceQuality,100) : 75; + int quality = sourceQuality >= 0 ? qMin(int(sourceQuality),100) : 75; #if defined(Q_OS_UNIXWARE) jpeg_set_quality(&cinfo, quality, B_TRUE /* limit to baseline-JPEG values */); jpeg_start_compress(&cinfo, B_TRUE); diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 04f3b4f332..cccb29bb7b 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -181,7 +181,7 @@ public: void setGamma(float); bool writeImage(const QImage& img, int x, int y); - bool writeImage(const QImage& img, int quality, const QString &description, int x, int y); + bool writeImage(const QImage& img, volatile int quality, const QString &description, int x, int y); bool writeImage(const QImage& img) { return writeImage(img, 0, 0); } bool writeImage(const QImage& img, int quality, const QString &description) @@ -801,7 +801,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, int off_x, int off_y) return writeImage(image, -1, QString(), off_x, off_y); } -bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, int quality_in, const QString &description, +bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, volatile int quality_in, const QString &description, int off_x_in, int off_y_in) { QPoint offset = image.offset();