Commit d32f8ed4 authored by Wescoeur's avatar Wescoeur

fix(QExifImageHeader): clean compilation warnings

parent 2987cdd5
...@@ -41,8 +41,6 @@ ...@@ -41,8 +41,6 @@
// This file was copied from Qt Extended 4.5 // This file was copied from Qt Extended 4.5
#include "QExifImageHeader.h"
#include <QFile> #include <QFile>
#include <QImage> #include <QImage>
#include <QDataStream> #include <QDataStream>
...@@ -51,6 +49,10 @@ ...@@ -51,6 +49,10 @@
#include <QtDebug> #include <QtDebug>
#include <QTextCodec> #include <QTextCodec>
#include "Utils.hpp"
#include "QExifImageHeader.h"
/*! /*!
\typedef QExifSRational \typedef QExifSRational
...@@ -484,19 +486,18 @@ QString QExifValue::toString () const { ...@@ -484,19 +486,18 @@ QString QExifValue::toString () const {
QTextCodec *codec = QTextCodec::codecForName("JIS X 0208"); QTextCodec *codec = QTextCodec::codecForName("JIS X 0208");
if (codec) if (codec)
return codec->toUnicode(string); return codec->toUnicode(string);
} } break;
break;
case UnicodeEncoding: { case UnicodeEncoding: {
QTextCodec *codec = QTextCodec::codecForName("UTF-16"); QTextCodec *codec = QTextCodec::codecForName("UTF-16");
if (codec) if (codec)
return codec->toUnicode(string); return codec->toUnicode(string);
} } UTILS_NO_BREAK;
case UndefinedEncoding: case UndefinedEncoding:
return QString::fromLocal8Bit(string.constData(), string.length()); return QString::fromLocal8Bit(string.constData(), string.length());
default: default:
break; break;
} }
} } UTILS_NO_BREAK;
default: default:
return QString(); return QString();
} }
...@@ -1025,27 +1026,17 @@ quint32 QExifImageHeader::sizeOf (const QExifValue &value) const { ...@@ -1025,27 +1026,17 @@ quint32 QExifImageHeader::sizeOf (const QExifValue &value) const {
switch (value.type()) { switch (value.type()) {
case QExifValue::Byte: case QExifValue::Byte:
case QExifValue::Undefined: case QExifValue::Undefined:
return value.count() > 4 return value.count() > 4 ? 12 + value.count() : 12;
? 12 + value.count()
: 12;
case QExifValue::Ascii: case QExifValue::Ascii:
return value.count() > 4 return value.count() > 4 ? 12 + value.count() : 12;
? 12 + value.count()
: 12;
case QExifValue::Short: case QExifValue::Short:
return value.count() > 2 return value.count() > 2 ? static_cast<quint32>(12 + value.count() * sizeof(quint16)) : 12;
? 12 + value.count() * sizeof(quint16)
: 12;
case QExifValue::Long: case QExifValue::Long:
case QExifValue::SignedLong: case QExifValue::SignedLong:
return value.count() > 1 return value.count() > 1 ? static_cast<quint32>(12 + value.count() * sizeof(quint32)) : 12;
? 12 + value.count() * sizeof(quint32)
: 12;
case QExifValue::Rational: case QExifValue::Rational:
case QExifValue::SignedRational: case QExifValue::SignedRational:
return value.count() > 0 return value.count() > 0 ? static_cast<quint32>(12 + value.count() * sizeof(quint32) * 2) : 12;
? 12 + value.count() * sizeof(quint32) * 2
: 12;
default: default:
return 0; return 0;
} }
...@@ -1471,7 +1462,7 @@ QMap<T, QExifValue> QExifImageHeader::readIfdValues ( ...@@ -1471,7 +1462,7 @@ QMap<T, QExifValue> QExifImageHeader::readIfdValues (
bool QExifImageHeader::read (QIODevice *device) { bool QExifImageHeader::read (QIODevice *device) {
clear(); clear();
int startPos = device->pos(); int startPos = static_cast<int>(device->pos());
QDataStream stream(device); QDataStream stream(device);
...@@ -1590,7 +1581,7 @@ quint32 QExifImageHeader::writeExifHeader (QDataStream &stream, quint16 tag, con ...@@ -1590,7 +1581,7 @@ quint32 QExifImageHeader::writeExifHeader (QDataStream &stream, quint16 tag, con
} else { } else {
stream << offset; stream << offset;
offset += value.count() * sizeof(quint16); offset += static_cast<quint32>(value.count() * sizeof(quint16));
} }
break; break;
case QExifValue::Long: case QExifValue::Long:
...@@ -1601,7 +1592,7 @@ quint32 QExifImageHeader::writeExifHeader (QDataStream &stream, quint16 tag, con ...@@ -1601,7 +1592,7 @@ quint32 QExifImageHeader::writeExifHeader (QDataStream &stream, quint16 tag, con
} else { } else {
stream << offset; stream << offset;
offset += value.count() * sizeof(quint32); offset += static_cast<quint32>(value.count() * sizeof(quint32));
} }
break; break;
case QExifValue::SignedLong: case QExifValue::SignedLong:
...@@ -1612,7 +1603,7 @@ quint32 QExifImageHeader::writeExifHeader (QDataStream &stream, quint16 tag, con ...@@ -1612,7 +1603,7 @@ quint32 QExifImageHeader::writeExifHeader (QDataStream &stream, quint16 tag, con
} else { } else {
stream << offset; stream << offset;
offset += value.count() * sizeof(qint32); offset += static_cast<quint32>(value.count() * sizeof(qint32));
} }
break; break;
case QExifValue::Rational: case QExifValue::Rational:
...@@ -1621,7 +1612,7 @@ quint32 QExifImageHeader::writeExifHeader (QDataStream &stream, quint16 tag, con ...@@ -1621,7 +1612,7 @@ quint32 QExifImageHeader::writeExifHeader (QDataStream &stream, quint16 tag, con
} else { } else {
stream << offset; stream << offset;
offset += value.count() * sizeof(quint32) * 2; offset += static_cast<quint32>(value.count() * sizeof(quint32) * 2);
} }
break; break;
case QExifValue::SignedRational: case QExifValue::SignedRational:
...@@ -1630,7 +1621,7 @@ quint32 QExifImageHeader::writeExifHeader (QDataStream &stream, quint16 tag, con ...@@ -1630,7 +1621,7 @@ quint32 QExifImageHeader::writeExifHeader (QDataStream &stream, quint16 tag, con
} else { } else {
stream << offset; stream << offset;
offset += value.count() * sizeof(qint32) * 2; offset += static_cast<quint32>(value.count() * sizeof(qint32) * 2);
} }
break; break;
default: default:
...@@ -1739,7 +1730,7 @@ qint64 QExifImageHeader::write (QIODevice *device) const { ...@@ -1739,7 +1730,7 @@ qint64 QExifImageHeader::write (QIODevice *device) const {
device->write("\x00\x00\x00\x08", 4); device->write("\x00\x00\x00\x08", 4);
} }
quint16 count = d->imageIfdValues.count() + 1; quint16 count = static_cast<quint16>(d->imageIfdValues.count() + 1);
quint32 offset = 26; quint32 offset = 26;
if (!d->gpsIfdValues.isEmpty()) { if (!d->gpsIfdValues.isEmpty()) {
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
// This file was copied from Qt Extended 4.5 // This file was copied from Qt Extended 4.5
#ifndef QEXIFIMAGEHEADER_H #ifndef QEXIFIMAGEHEADER_H_
#define QEXIFIMAGEHEADER_H #define QEXIFIMAGEHEADER_H_
#include <QPair> #include <QPair>
#include <QVector> #include <QVector>
...@@ -333,4 +333,4 @@ private: ...@@ -333,4 +333,4 @@ private:
QExifImageHeaderPrivate *d; QExifImageHeaderPrivate *d;
}; };
#endif // ifndef QEXIFIMAGEHEADER_H #endif // ifndef QEXIFIMAGEHEADER_H_
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
// ============================================================================= // =============================================================================
/* /*
* Define telling G++ that a 'break' statement has been deliberately omitted * Define telling g++ that a 'break' statement has been deliberately omitted
* in switch block. * in switch block.
*/ */
#ifndef UTILS_NO_BREAK #ifndef UTILS_NO_BREAK
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment