summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qiodevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r--src/corelib/io/qiodevice.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index c560bc7a03..52a78ad1c4 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -120,6 +120,14 @@ static void checkWarnMessage(const QIODevice *device, const char *function, cons
} \
} while (0)
+#define CHECK_MAXBYTEARRAYSIZE(function) \
+ do { \
+ if (maxSize >= MaxByteArraySize) { \
+ checkWarnMessage(this, #function, "maxSize argument exceeds QByteArray size limit"); \
+ maxSize = MaxByteArraySize - 1; \
+ } \
+ } while (0)
+
#define CHECK_WRITABLE(function, returnType) \
do { \
if ((d->openMode & WriteOnly) == 0) { \
@@ -1178,10 +1186,7 @@ QByteArray QIODevice::read(qint64 maxSize)
}
CHECK_MAXLEN(read, result);
- if (maxSize >= MaxByteArraySize) {
- checkWarnMessage(this, "read", "maxSize argument exceeds QByteArray size limit");
- maxSize = MaxByteArraySize - 1;
- }
+ CHECK_MAXBYTEARRAYSIZE(read);
result.resize(int(maxSize));
qint64 readBytes = read(result.data(), result.size());
@@ -1402,17 +1407,13 @@ QByteArray QIODevice::readLine(qint64 maxSize)
QByteArray result;
CHECK_MAXLEN(readLine, result);
+ CHECK_MAXBYTEARRAYSIZE(readLine);
#if defined QIODEVICE_DEBUG
printf("%p QIODevice::readLine(%lld), d->pos = %lld, d->buffer.size() = %lld\n",
this, maxSize, d->pos, d->buffer.size());
#endif
- if (maxSize >= MaxByteArraySize) {
- qWarning("QIODevice::read: maxSize argument exceeds QByteArray size limit");
- maxSize = MaxByteArraySize - 1;
- }
-
result.resize(int(maxSize));
qint64 readBytes = 0;
if (!result.size()) {