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 <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2012-08-15 19:25:44 +02:00 committed by Qt by Nokia
parent ed7b50fdb4
commit 624911e481
2 changed files with 5 additions and 5 deletions

View File

@ -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<QRgb> 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);

View File

@ -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();