diff options
| author | Ivan Solovev <ivan.solovev@qt.io> | 2024-01-26 12:50:46 +0100 |
|---|---|---|
| committer | Ivan Solovev <ivan.solovev@qt.io> | 2024-02-07 15:02:19 +0100 |
| commit | 0ed34d19926c60f3b74a58723c5c36f366e99d95 (patch) | |
| tree | adf06d68a344ded8c06fe01b9064a3764dc26fb4 /src/corelib/serialization/qdatastream.cpp | |
| parent | d4bb448cddce63e0c6a84a86020fa59dd32b2293 (diff) | |
QDataStream: use qint64 to represent size while reading and writing
Do that to avoid narrowing at the call site on 32-bit platforms.
Amends fd48ce0b73c74dafd5db27bc1f2752ef665df7ef
Found in 6.7 API review
Pick-to: 6.7
Change-Id: I31142399385521d973b2ed3789745569e44d5d63
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qdatastream.cpp')
| -rw-r--r-- | src/corelib/serialization/qdatastream.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp index 8d509c13863..7c4c5cc12af 100644 --- a/src/corelib/serialization/qdatastream.cpp +++ b/src/corelib/serialization/qdatastream.cpp @@ -758,13 +758,13 @@ bool QDataStream::isDeviceTransactionStarted() const \internal */ -qsizetype QDataStream::readBlock(char *data, qsizetype len) +qint64 QDataStream::readBlock(char *data, qint64 len) { // Disable reads on failure in transacted stream if (q_status != Ok && dev->isTransactionStarted()) return -1; - const qsizetype readResult = dev->read(data, len); + const qint64 readResult = dev->read(data, len); if (readResult != len) setStatus(ReadPastEnd); return readResult; @@ -1003,7 +1003,7 @@ QDataStream &QDataStream::operator>>(double &f) QDataStream &QDataStream::operator>>(char *&s) { - qsizetype len = 0; + qint64 len = 0; return readBytes(s, len); } @@ -1058,7 +1058,7 @@ QDataStream &QDataStream::operator>>(char32_t &c) \sa readRawData(), writeBytes() */ -QDataStream &QDataStream::readBytes(char *&s, qsizetype &l) +QDataStream &QDataStream::readBytes(char *&s, qint64 &l) { s = nullptr; l = 0; @@ -1070,7 +1070,7 @@ QDataStream &QDataStream::readBytes(char *&s, qsizetype &l) qsizetype len = qsizetype(length); if (length != len || length < 0) { - setStatus(SizeLimitExceeded); // Cannot store len in l + setStatus(SizeLimitExceeded); // Cannot store len return *this; } @@ -1109,7 +1109,7 @@ QDataStream &QDataStream::readBytes(char *&s, qsizetype &l) \sa readBytes(), QIODevice::read(), writeRawData() */ -qsizetype QDataStream::readRawData(char *s, qsizetype len) +qint64 QDataStream::readRawData(char *s, qint64 len) { CHECK_STREAM_PRECOND(-1) return readBlock(s, len); @@ -1390,7 +1390,7 @@ QDataStream &QDataStream::operator<<(char32_t c) \sa writeRawData(), readBytes() */ -QDataStream &QDataStream::writeBytes(const char *s, qsizetype len) +QDataStream &QDataStream::writeBytes(const char *s, qint64 len) { if (len < 0) { q_status = WriteFailed; @@ -1411,10 +1411,10 @@ QDataStream &QDataStream::writeBytes(const char *s, qsizetype len) \sa writeBytes(), QIODevice::write(), readRawData() */ -qsizetype QDataStream::writeRawData(const char *s, qsizetype len) +qint64 QDataStream::writeRawData(const char *s, qint64 len) { CHECK_STREAM_WRITE_PRECOND(-1) - qsizetype ret = dev->write(s, len); + qint64 ret = dev->write(s, len); if (ret != len) q_status = WriteFailed; return ret; |
