From cae4f72585f06023efc28e00d4341c87864e5961 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Tue, 4 Jun 2019 12:03:47 +0200 Subject: Fix calculation of MAX_TRANSMIT_SPAN Fixed a wrong closing parenthesis location, based on the RFC. Change-Id: I3aa369a66411bbef1ca6f7b8b8c72fad9281c60c Reviewed-by: Alex Blasche --- src/coap/qcoapprotocol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/coap/qcoapprotocol.cpp b/src/coap/qcoapprotocol.cpp index 3a6f3ca..e5b7895 100644 --- a/src/coap/qcoapprotocol.cpp +++ b/src/coap/qcoapprotocol.cpp @@ -954,7 +954,9 @@ quint16 QCoapProtocol::blockSize() const */ uint QCoapProtocol::maximumTransmitSpan() const { - return static_cast(ackTimeout() * (1u << (maximumRetransmitCount() - 1)) * ackRandomFactor()); + return static_cast(ackTimeout() + * ((1u << maximumRetransmitCount()) - 1) + * ackRandomFactor()); } /*! -- cgit v1.2.3 From ca1a8d80f162d26bd280a7c05f0553946a06117e Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Mon, 3 Jun 2019 14:21:54 +0200 Subject: Fix warnings - qcoapprotocol.cpp:387: implicit conversion changes signedness: 'int' to 'uint' (aka 'unsigned int') - tst_qcoapclient.cpp:365: implicit conversion loses integer precision: 'int' to 'quint16' (aka 'unsigned short') - tst_qcoapclient.cpp:502: implicit conversion changes signedness: 'int' to 'uint' (aka 'unsigned int') - tst_qcoapclient.cpp:504: implicit conversion changes signedness: 'int' to 'uint' (aka 'unsigned int') Change-Id: I5bec42fc69925f04641285c6473d9ddc3ba6ec56 Reviewed-by: Karsten Heimrich --- src/coap/qcoapprotocol.cpp | 4 ++-- tests/auto/qcoapclient/tst_qcoapclient.cpp | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/coap/qcoapprotocol.cpp b/src/coap/qcoapprotocol.cpp index e5b7895..30ee188 100644 --- a/src/coap/qcoapprotocol.cpp +++ b/src/coap/qcoapprotocol.cpp @@ -383,8 +383,8 @@ void QCoapProtocolPrivate::onFrameReceived(const QByteArray &data, const QHostAd } // Send next block, ask for next block, or process the final reply - if (reply->hasMoreBlocksToSend()) { - request->setToSendBlock(reply->nextBlockToSend(), blockSize); + if (reply->hasMoreBlocksToSend() && reply->nextBlockToSend() >= 0) { + request->setToSendBlock(static_cast(reply->nextBlockToSend()), blockSize); request->setMessageId(generateUniqueMessageId()); sendRequest(request); } else if (reply->hasMoreBlocksToReceive()) { diff --git a/tests/auto/qcoapclient/tst_qcoapclient.cpp b/tests/auto/qcoapclient/tst_qcoapclient.cpp index 20f1cab..523c3ae 100644 --- a/tests/auto/qcoapclient/tst_qcoapclient.cpp +++ b/tests/auto/qcoapclient/tst_qcoapclient.cpp @@ -362,7 +362,7 @@ void tst_QCoapClient::setBlockSize() QFETCH(int, blockSizeExpected); QCoapClientForTests client; - client.setBlockSize(blockSizeSet); + client.setBlockSize(static_cast(blockSizeSet)); QEventLoop eventLoop; QTimer::singleShot(1000, &eventLoop, &QEventLoop::quit); @@ -483,19 +483,19 @@ void tst_QCoapClient::socketError() } void tst_QCoapClient::timeout_data() { - QTest::addColumn("timeout"); - QTest::addColumn("maximumRetransmitCount"); + QTest::addColumn("timeout"); + QTest::addColumn("maximumRetransmitCount"); - QTest::newRow("2000/0") << 2000 << 0; - QTest::newRow("2000/2") << 2000 << 2; - QTest::newRow("4000/0") << 4000 << 0; + QTest::newRow("2000/0") << 2000u << 0u; + QTest::newRow("2000/2") << 2000u << 2u; + QTest::newRow("4000/0") << 4000u << 0u; } void tst_QCoapClient::timeout() { #ifdef QT_BUILD_INTERNAL - QFETCH(int, timeout); - QFETCH(int, maximumRetransmitCount); + QFETCH(uint, timeout); + QFETCH(uint, maximumRetransmitCount); QCoapClientForTests client; // Trigger a network timeout @@ -514,7 +514,7 @@ void tst_QCoapClient::timeout() QSignalSpy spyReplyFinished(reply.data(), &QCoapReply::finished); // Check timeout upper limit - int transmissions = maximumRetransmitCount + 1; + uint transmissions = maximumRetransmitCount + 1; // 10% Precision expected at least, plus timer precision QTRY_COMPARE_WITH_TIMEOUT(spyReplyError.count(), 1, static_cast( -- cgit v1.2.3 From 70cf78af0aa55f68ade932ba3070a2f3dbe87181 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Fri, 14 Jun 2019 14:42:14 +0200 Subject: Fix compilation with the latest qtbase dev branch Copies of the QObjectData (as a result, also QObjectPrivate) have been disabled recently. Removed unnecessary copy constructors of the private classes and their usages. Change-Id: I15dd766abc88a657a267cbdc95f0c95346a47f72 Reviewed-by: Karsten Heimrich --- src/coap/qcoapinternalmessage.cpp | 10 ---------- src/coap/qcoapinternalmessage_p.h | 2 -- src/coap/qcoapinternalreply.cpp | 9 --------- src/coap/qcoapinternalreply_p.h | 3 --- 4 files changed, 24 deletions(-) diff --git a/src/coap/qcoapinternalmessage.cpp b/src/coap/qcoapinternalmessage.cpp index 59f63ba..fe4a34c 100644 --- a/src/coap/qcoapinternalmessage.cpp +++ b/src/coap/qcoapinternalmessage.cpp @@ -88,16 +88,6 @@ QCoapInternalMessage::QCoapInternalMessage(const QCoapMessage &message, QObject d->message = message; } -/*! - \internal - - Constructs a copy of \a other and sets \a parent as the parent object. -*/ -QCoapInternalMessage::QCoapInternalMessage(const QCoapInternalMessage &other, QObject *parent) : - QObject(*new QCoapInternalMessagePrivate(*other.d_func()), parent) -{ -} - /*! \internal Constructs a new QCoapInternalMessage with \a dd as the d_ptr. diff --git a/src/coap/qcoapinternalmessage_p.h b/src/coap/qcoapinternalmessage_p.h index 8ed1309..d6a08af 100644 --- a/src/coap/qcoapinternalmessage_p.h +++ b/src/coap/qcoapinternalmessage_p.h @@ -54,7 +54,6 @@ class Q_AUTOTEST_EXPORT QCoapInternalMessage : public QObject public: explicit QCoapInternalMessage(QObject *parent = nullptr); explicit QCoapInternalMessage(const QCoapMessage &message, QObject *parent = nullptr); - QCoapInternalMessage(const QCoapInternalMessage &other, QObject *parent = nullptr); virtual ~QCoapInternalMessage() {} void addOption(QCoapOption::OptionName name, const QByteArray &value); @@ -84,7 +83,6 @@ class Q_AUTOTEST_EXPORT QCoapInternalMessagePrivate : public QObjectPrivate { public: QCoapInternalMessagePrivate() = default; - QCoapInternalMessagePrivate(const QCoapInternalMessagePrivate &other) = default; ~QCoapInternalMessagePrivate(); QCoapMessage message; diff --git a/src/coap/qcoapinternalreply.cpp b/src/coap/qcoapinternalreply.cpp index b795046..2e7495c 100644 --- a/src/coap/qcoapinternalreply.cpp +++ b/src/coap/qcoapinternalreply.cpp @@ -56,15 +56,6 @@ QCoapInternalReply::QCoapInternalReply(QObject *parent) : { } -/*! - \internal - Constructs a copy of \a other with \a parent as the parent obect. -*/ -QCoapInternalReply::QCoapInternalReply(const QCoapInternalReply &other, QObject *parent) : - QCoapInternalMessage(*new QCoapInternalReplyPrivate(*other.d_func()), parent) -{ -} - /*! \internal Creates a QCoapInternalReply from the CoAP \a reply frame. diff --git a/src/coap/qcoapinternalreply_p.h b/src/coap/qcoapinternalreply_p.h index f144b47..4e9d60b 100644 --- a/src/coap/qcoapinternalreply_p.h +++ b/src/coap/qcoapinternalreply_p.h @@ -55,7 +55,6 @@ class Q_AUTOTEST_EXPORT QCoapInternalReply : public QCoapInternalMessage Q_OBJECT public: explicit QCoapInternalReply(QObject *parent = nullptr); - QCoapInternalReply(const QCoapInternalReply &other, QObject *parent = nullptr); static QCoapInternalReply *createFromFrame(const QByteArray &frame, QObject *parent = nullptr); void appendData(const QByteArray &data); @@ -84,6 +83,4 @@ public: QT_END_NAMESPACE -Q_DECLARE_METATYPE(QCoapInternalReply) - #endif // QCOAPINTERNALREPLY_H -- cgit v1.2.3 From 9272983e464713df9b768291d531c2d687345d74 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Fri, 14 Jun 2019 14:54:25 +0200 Subject: Remove deprecated QLatin1Literal Change-Id: If2376d7d38689001bc93ebd962507b21a05a09f9 Reviewed-by: Karsten Heimrich --- tests/auto/qcoapclient/tst_qcoapclient.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qcoapclient/tst_qcoapclient.cpp b/tests/auto/qcoapclient/tst_qcoapclient.cpp index 523c3ae..5ca695c 100644 --- a/tests/auto/qcoapclient/tst_qcoapclient.cpp +++ b/tests/auto/qcoapclient/tst_qcoapclient.cpp @@ -224,7 +224,7 @@ void tst_QCoapClient::incorrectUrls() else if (qstrcmp(QTest::currentDataTag(), "discover") == 0) reply.reset(client.discover(url)); else { - QString error = QLatin1Literal("Unrecognized method '") + QTest::currentDataTag() + "'"; + QString error = QLatin1String("Unrecognized method '") + QTest::currentDataTag() + "'"; QFAIL(qPrintable(error)); } @@ -275,7 +275,7 @@ void tst_QCoapClient::methods() else if (qstrncmp(QTest::currentDataTag(), "delete", 6) == 0) reply.reset(client.deleteResource(request)); else { - QString error = QLatin1Literal("Unrecognized method '") + QTest::currentDataTag() + "'"; + QString error = QLatin1String("Unrecognized method '") + QTest::currentDataTag() + "'"; QFAIL(qPrintable(error)); } @@ -303,7 +303,7 @@ void tst_QCoapClient::methods() QVERIFY(replyData.isEmpty()); QCOMPARE(reply->responseCode(), QtCoap::ResponseCode::Deleted); } else { - QString error = QLatin1Literal("Unrecognized method '") + QTest::currentDataTag() + "'"; + QString error = QLatin1String("Unrecognized method '") + QTest::currentDataTag() + "'"; QFAIL(qPrintable(error)); } } -- cgit v1.2.3