diff options
author | Mate Barany <mate.barany@qt.io> | 2023-04-24 15:38:07 +0200 |
---|---|---|
committer | Mate Barany <mate.barany@qt.io> | 2023-04-27 16:14:49 +0200 |
commit | 84e3561bf8a2df716585955a54f59819debaaf9b (patch) | |
tree | b76d904d4b269c55be0e6457417dcde3581fac4f /examples | |
parent | 15df42c95d30e5464654df6224bd7125a6b11e05 (diff) |
Fix some compiler warnings in the MQTT WebsocketSubscription Example
Fix some warnings that were reported by the MSVC compiler with the Wall
setting:
- use static_cast for signed/unsigned conversion
- use QString::fromUtf8 instead of the QByteArray constructor
Pick-to: 6.5
Task-number: QTBUG-110893
Change-Id: Ic982d3c16feb1ebcef729b4dfd023cc3b5017fec
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/mqtt/websocketsubscription/websocketiodevice.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/mqtt/websocketsubscription/websocketiodevice.cpp b/examples/mqtt/websocketsubscription/websocketiodevice.cpp index 74ac77e..479688a 100644 --- a/examples/mqtt/websocketsubscription/websocketiodevice.cpp +++ b/examples/mqtt/websocketsubscription/websocketiodevice.cpp @@ -17,7 +17,7 @@ WebSocketIODevice::WebSocketIODevice(QObject *parent) bool WebSocketIODevice::open(QIODevice::OpenMode mode) { QWebSocketHandshakeOptions options; - options.setSubprotocols({m_protocol}); + options.setSubprotocols(QStringList{ QString::fromUtf8(m_protocol) }); m_socket.open(m_url, options); @@ -33,7 +33,7 @@ void WebSocketIODevice::close() qint64 WebSocketIODevice::readData(char *data, qint64 maxlen) { qint64 bytesToRead = qMin(maxlen, (qint64)m_buffer.size()); - memcpy(data, m_buffer.constData(), bytesToRead); + memcpy(data, m_buffer.constData(), static_cast<size_t>(bytesToRead)); m_buffer = m_buffer.right(m_buffer.size() - bytesToRead); return bytesToRead; } |