QtCore: Fix const correctness in old style casts
Found with GCC's -Wcast-qual. Change-Id: Ia0aac2f09e9245339951ffff13c8d4b2920a11fb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
826a83937d
commit
28f5207ca0
|
|
@ -36,7 +36,7 @@ static void
|
|||
byteSwap(UWORD32 *buf, unsigned words)
|
||||
{
|
||||
const quint32 byteOrderTest = 0x1;
|
||||
if (((char *)&byteOrderTest)[0] == 0) {
|
||||
if (((const char *)&byteOrderTest)[0] == 0) {
|
||||
md5byte *p = (md5byte *)buf;
|
||||
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const
|
|||
{
|
||||
// do sixteen characters at a time
|
||||
for ( ; end - src >= 16; src += 16, dst += 16) {
|
||||
__m128i data1 = _mm_loadu_si128((__m128i*)src);
|
||||
__m128i data2 = _mm_loadu_si128(1+(__m128i*)src);
|
||||
__m128i data1 = _mm_loadu_si128((const __m128i*)src);
|
||||
__m128i data2 = _mm_loadu_si128(1+(const __m128i*)src);
|
||||
|
||||
|
||||
// check if everything is ASCII
|
||||
|
|
@ -90,7 +90,7 @@ static inline bool simdDecodeAscii(ushort *&dst, const uchar *&nextAscii, const
|
|||
{
|
||||
// do sixteen characters at a time
|
||||
for ( ; end - src >= 16; src += 16, dst += 16) {
|
||||
__m128i data = _mm_loadu_si128((__m128i*)src);
|
||||
__m128i data = _mm_loadu_si128((const __m128i*)src);
|
||||
|
||||
#ifdef __AVX2__
|
||||
const int BitSpacing = 2;
|
||||
|
|
@ -390,7 +390,7 @@ QString QUtf8::convertToUnicode(const char *chars, int len, QTextCodec::Converte
|
|||
*dst++ = QChar::ReplacementCharacter;
|
||||
}
|
||||
|
||||
result.truncate(dst - (ushort *)result.unicode());
|
||||
result.truncate(dst - (const ushort *)result.unicode());
|
||||
if (state) {
|
||||
state->invalidChars += invalid;
|
||||
if (headerdone)
|
||||
|
|
@ -469,7 +469,7 @@ QString QUtf16::convertToUnicode(const char *chars, int len, QTextCodec::Convert
|
|||
endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness;
|
||||
|
||||
QString result(len, Qt::Uninitialized); // worst case
|
||||
QChar *qch = (QChar *)result.unicode();
|
||||
QChar *qch = (QChar *)result.data();
|
||||
while (len--) {
|
||||
if (half) {
|
||||
QChar ch;
|
||||
|
|
@ -600,7 +600,7 @@ QString QUtf32::convertToUnicode(const char *chars, int len, QTextCodec::Convert
|
|||
|
||||
QString result;
|
||||
result.resize((num + len) >> 2 << 1); // worst case
|
||||
QChar *qch = (QChar *)result.unicode();
|
||||
QChar *qch = (QChar *)result.data();
|
||||
|
||||
const char *end = chars + len;
|
||||
while (chars < end) {
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ qint64 QBuffer::writeData(const char *data, qint64 len)
|
|||
}
|
||||
}
|
||||
|
||||
memcpy(d->buf->data() + pos(), (uchar *)data, int(len));
|
||||
memcpy(d->buf->data() + pos(), data, int(len));
|
||||
|
||||
#ifndef QT_NO_QOBJECT
|
||||
d->writtenSinceLastEmit += len;
|
||||
|
|
|
|||
|
|
@ -819,13 +819,13 @@ bool QFSFileEngine::extension(Extension extension, const ExtensionOption *option
|
|||
return feof(d->fh);
|
||||
|
||||
if (extension == MapExtension) {
|
||||
const MapExtensionOption *options = (MapExtensionOption*)(option);
|
||||
const MapExtensionOption *options = (const MapExtensionOption*)(option);
|
||||
MapExtensionReturn *returnValue = static_cast<MapExtensionReturn*>(output);
|
||||
returnValue->address = d->map(options->offset, options->size, options->flags);
|
||||
return (returnValue->address != 0);
|
||||
}
|
||||
if (extension == UnMapExtension) {
|
||||
UnMapExtensionOption *options = (UnMapExtensionOption*)option;
|
||||
const UnMapExtensionOption *options = (const UnMapExtensionOption*)option;
|
||||
return d->unmap(options->address);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -956,7 +956,7 @@ public:
|
|||
} else
|
||||
#endif
|
||||
{
|
||||
delete [] (uchar *)mappingBuffer();
|
||||
delete [] mappingBuffer();
|
||||
}
|
||||
}
|
||||
QString mappingFile() const { return fileName; }
|
||||
|
|
@ -1450,13 +1450,13 @@ bool QResourceFileEngine::extension(Extension extension, const ExtensionOption *
|
|||
{
|
||||
Q_D(QResourceFileEngine);
|
||||
if (extension == MapExtension) {
|
||||
const MapExtensionOption *options = (MapExtensionOption*)(option);
|
||||
const MapExtensionOption *options = (const MapExtensionOption*)(option);
|
||||
MapExtensionReturn *returnValue = static_cast<MapExtensionReturn*>(output);
|
||||
returnValue->address = d->map(options->offset, options->size, options->flags);
|
||||
return (returnValue->address != 0);
|
||||
}
|
||||
if (extension == UnMapExtension) {
|
||||
UnMapExtensionOption *options = (UnMapExtensionOption*)option;
|
||||
const UnMapExtensionOption *options = (const UnMapExtensionOption*)option;
|
||||
return d->unmap(options->address);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -438,7 +438,7 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint
|
|||
static const char *const empty = "";
|
||||
if (argc == 0 || argv == 0) {
|
||||
argc = 0;
|
||||
argv = (char **)∅
|
||||
argv = const_cast<char **>(&empty);
|
||||
}
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
||||
if (!isArgvModified(argc, argv)) {
|
||||
|
|
|
|||
|
|
@ -1840,7 +1840,8 @@ public:
|
|||
void delegate(const T *where) { DestructorImpl<T>::Destruct(m_type, const_cast<T*>(where)); }
|
||||
void delegate(const void *) {}
|
||||
void delegate(const QMetaTypeSwitcher::UnknownType*) {}
|
||||
void delegate(const QMetaTypeSwitcher::NotBuiltinType *where) { customTypeDestructor(m_type, (void*)where); }
|
||||
void delegate(const QMetaTypeSwitcher::NotBuiltinType *where)
|
||||
{ customTypeDestructor(m_type, const_cast<void *>(static_cast<const void *>(where))); }
|
||||
|
||||
private:
|
||||
static void customTypeDestructor(const int type, void *where)
|
||||
|
|
|
|||
|
|
@ -4093,7 +4093,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
|
|||
QDebugStateSaver saver(dbg);
|
||||
if (!o)
|
||||
return dbg << "QObject(0x0)";
|
||||
dbg.nospace() << o->metaObject()->className() << '(' << (void *)o;
|
||||
dbg.nospace() << o->metaObject()->className() << '(' << (const void *)o;
|
||||
if (!o->objectName().isEmpty())
|
||||
dbg << ", name = " << o->objectName();
|
||||
dbg << ')';
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public:
|
|||
raw += strlen("QTMETADATA ");
|
||||
// the size of the embedded JSON object can be found 8 bytes into the data (see qjson_p.h),
|
||||
// but doesn't include the size of the header (8 bytes)
|
||||
QByteArray json(raw, qFromLittleEndian<uint>(*(uint *)(raw + 8)) + 8);
|
||||
QByteArray json(raw, qFromLittleEndian<uint>(*(const uint *)(raw + 8)) + 8);
|
||||
return QJsonDocument::fromBinaryData(json);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -543,7 +543,7 @@ QUuid QUuid::fromRfc4122(const QByteArray &bytes)
|
|||
QString QUuid::toString() const
|
||||
{
|
||||
QString result(38, Qt::Uninitialized);
|
||||
ushort *data = (ushort *)result.unicode();
|
||||
ushort *data = (ushort *)result.data();
|
||||
|
||||
_q_uuidToHex(data, data1, data2, data3, data4);
|
||||
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ QByteArray qCompress(const uchar* data, int nbytes, int compressionLevel)
|
|||
int res;
|
||||
do {
|
||||
bazip.resize(len + 4);
|
||||
res = ::compress2((uchar*)bazip.data()+4, &len, (uchar*)data, nbytes, compressionLevel);
|
||||
res = ::compress2((uchar*)bazip.data()+4, &len, data, nbytes, compressionLevel);
|
||||
|
||||
switch (res) {
|
||||
case Z_OK:
|
||||
|
|
@ -601,7 +601,7 @@ QByteArray qUncompress(const uchar* data, int nbytes)
|
|||
d->size = 0; // Shut up valgrind "uninitialized variable" warning
|
||||
|
||||
int res = ::uncompress((uchar*)d->data(), &len,
|
||||
(uchar*)data+4, nbytes-4);
|
||||
data+4, nbytes-4);
|
||||
|
||||
switch (res) {
|
||||
case Z_OK:
|
||||
|
|
@ -2148,9 +2148,9 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after
|
|||
}
|
||||
|
||||
if (a != after)
|
||||
::free((char *)a);
|
||||
::free(const_cast<char *>(a));
|
||||
if (b != before)
|
||||
::free((char *)b);
|
||||
::free(const_cast<char *>(b));
|
||||
|
||||
|
||||
return *this;
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ void qt_from_latin1(ushort *dst, const char *str, size_t size)
|
|||
|
||||
// we're going to read str[offset..offset+15] (16 bytes)
|
||||
for ( ; str + offset + 15 < e; offset += 16) {
|
||||
const __m128i chunk = _mm_loadu_si128((__m128i*)(str + offset)); // load
|
||||
const __m128i chunk = _mm_loadu_si128((const __m128i*)(str + offset)); // load
|
||||
#ifdef __AVX2__
|
||||
// zero extend to an YMM register
|
||||
const __m256i extended = _mm256_cvtepu8_epi16(chunk);
|
||||
|
|
@ -317,10 +317,10 @@ static void qt_to_latin1(uchar *dst, const ushort *src, int length)
|
|||
|
||||
// we're going to write to dst[offset..offset+15] (16 bytes)
|
||||
for ( ; dst + offset + 15 < e; offset += 16) {
|
||||
__m128i chunk1 = _mm_loadu_si128((__m128i*)(src + offset)); // load
|
||||
__m128i chunk1 = _mm_loadu_si128((const __m128i*)(src + offset)); // load
|
||||
chunk1 = mergeQuestionMarks(chunk1);
|
||||
|
||||
__m128i chunk2 = _mm_loadu_si128((__m128i*)(src + offset + 8)); // load
|
||||
__m128i chunk2 = _mm_loadu_si128((const __m128i*)(src + offset + 8)); // load
|
||||
chunk2 = mergeQuestionMarks(chunk2);
|
||||
|
||||
// pack the two vector to 16 x 8bits elements
|
||||
|
|
@ -459,8 +459,8 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
|
|||
|
||||
// we're going to read ptr[0..15] (16 bytes)
|
||||
for ( ; ptr + 15 < reinterpret_cast<const char *>(a); ptr += 16) {
|
||||
__m128i a_data = _mm_loadu_si128((__m128i*)ptr);
|
||||
__m128i b_data = _mm_loadu_si128((__m128i*)(ptr + distance));
|
||||
__m128i a_data = _mm_loadu_si128((const __m128i*)ptr);
|
||||
__m128i b_data = _mm_loadu_si128((const __m128i*)(ptr + distance));
|
||||
__m128i result = _mm_cmpeq_epi16(a_data, b_data);
|
||||
uint mask = ~_mm_movemask_epi8(result);
|
||||
if (ushort(mask)) {
|
||||
|
|
@ -542,14 +542,14 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
|
|||
for ( ; uc + offset + 15 < e; offset += 16) {
|
||||
// similar to fromLatin1_helper:
|
||||
// load 16 bytes of Latin 1 data
|
||||
__m128i chunk = _mm_loadu_si128((__m128i*)(c + offset));
|
||||
__m128i chunk = _mm_loadu_si128((const __m128i*)(c + offset));
|
||||
|
||||
# ifdef __AVX2__
|
||||
// expand Latin 1 data via zero extension
|
||||
__m256i ldata = _mm256_cvtepu8_epi16(chunk);
|
||||
|
||||
// load UTF-16 data and compare
|
||||
__m256i ucdata = _mm256_loadu_si256((__m256i*)(uc + offset));
|
||||
__m256i ucdata = _mm256_loadu_si256((const __m256i*)(uc + offset));
|
||||
__m256i result = _mm256_cmpeq_epi16(ldata, ucdata);
|
||||
|
||||
uint mask = ~_mm256_movemask_epi8(result);
|
||||
|
|
@ -559,8 +559,8 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
|
|||
__m128i secondHalf = _mm_unpackhi_epi8(chunk, nullmask);
|
||||
|
||||
// load UTF-16 data and compare
|
||||
__m128i ucdata1 = _mm_loadu_si128((__m128i*)(uc + offset));
|
||||
__m128i ucdata2 = _mm_loadu_si128((__m128i*)(uc + offset + 8));
|
||||
__m128i ucdata1 = _mm_loadu_si128((const __m128i*)(uc + offset));
|
||||
__m128i ucdata2 = _mm_loadu_si128((const __m128i*)(uc + offset + 8));
|
||||
__m128i result1 = _mm_cmpeq_epi16(firstHalf, ucdata1);
|
||||
__m128i result2 = _mm_cmpeq_epi16(secondHalf, ucdata2);
|
||||
|
||||
|
|
@ -578,10 +578,10 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
|
|||
// we'll read uc[offset..offset+7] (16 bytes) and c[offset..offset+7] (8 bytes)
|
||||
if (uc + offset + 7 < e) {
|
||||
// same, but we're using an 8-byte load
|
||||
__m128i chunk = _mm_cvtsi64_si128(*(long long *)(c + offset));
|
||||
__m128i chunk = _mm_cvtsi64_si128(*(const long long *)(c + offset));
|
||||
__m128i secondHalf = _mm_unpacklo_epi8(chunk, nullmask);
|
||||
|
||||
__m128i ucdata = _mm_loadu_si128((__m128i*)(uc + offset));
|
||||
__m128i ucdata = _mm_loadu_si128((const __m128i*)(uc + offset));
|
||||
__m128i result = _mm_cmpeq_epi16(secondHalf, ucdata);
|
||||
uint mask = ~_mm_movemask_epi8(result);
|
||||
if (ushort(mask)) {
|
||||
|
|
@ -673,7 +673,7 @@ static int findChar(const QChar *str, int len, QChar ch, int from,
|
|||
|
||||
// we're going to read n[0..7] (16 bytes)
|
||||
for (const ushort *next = n + 8; next <= e; n = next, next += 8) {
|
||||
__m128i data = _mm_loadu_si128((__m128i*)n);
|
||||
__m128i data = _mm_loadu_si128((const __m128i*)n);
|
||||
__m128i result = _mm_cmpeq_epi16(data, mch);
|
||||
uint mask = _mm_movemask_epi8(result);
|
||||
if (ushort(mask)) {
|
||||
|
|
@ -2622,7 +2622,7 @@ bool operator<(const QString &s1, const QString &s2)
|
|||
*/
|
||||
bool QString::operator<(QLatin1String other) const
|
||||
{
|
||||
const uchar *c = (uchar *) other.latin1();
|
||||
const uchar *c = (const uchar *) other.latin1();
|
||||
if (!c || *c == 0)
|
||||
return false;
|
||||
|
||||
|
|
@ -2727,7 +2727,7 @@ bool QString::operator<(QLatin1String other) const
|
|||
*/
|
||||
bool QString::operator>(QLatin1String other) const
|
||||
{
|
||||
const uchar *c = (uchar *) other.latin1();
|
||||
const uchar *c = (const uchar *) other.latin1();
|
||||
if (!c || *c == '\0')
|
||||
return !isEmpty();
|
||||
|
||||
|
|
@ -5270,7 +5270,7 @@ int QString::compare_helper(const QChar *data1, int length1, QLatin1String s2,
|
|||
{
|
||||
const ushort *uc = reinterpret_cast<const ushort *>(data1);
|
||||
const ushort *uce = uc + length1;
|
||||
const uchar *c = (uchar *)s2.latin1();
|
||||
const uchar *c = (const uchar *)s2.latin1();
|
||||
|
||||
if (!c)
|
||||
return length1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue