From 06431d071a4e460a0653be1d320d452c54bc36f2 Mon Sep 17 00:00:00 2001 From: xiaoming <2014500726@smail.xtu.edu.cn> Date: Sun, 1 Sep 2024 16:14:16 +0800 Subject: [PATCH] clean warning Signed-off-by: xiaoming <2014500726@smail.xtu.edu.cn> --- lib/Qtftp/qtftp.cpp | 11 +++++++---- lib/qextserialport/qextserialenumerator_win.cpp | 8 ++++---- lib/qtermwidget/TerminalDisplay.cpp | 3 ++- lib/qtermwidget/util/CharWidth.cpp | 3 ++- lib/qtkeychain/keychain_win.cpp | 2 +- lib/qzmodem/qrecvzmodem.cpp | 12 ++++++------ lib/sqlite/sqlite3.c | 2 ++ 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/lib/Qtftp/qtftp.cpp b/lib/Qtftp/qtftp.cpp index 0cab02e5..3cddd9a8 100644 --- a/lib/Qtftp/qtftp.cpp +++ b/lib/Qtftp/qtftp.cpp @@ -221,8 +221,10 @@ void QTftp::client_get(QString path, QString server) m_segsize = 512; m_timeout = 1000; struct tftp_header *th = (struct tftp_header *)buffer; - strcpy(th->path, name.fileName().toUtf8().constData()); - strcpy(th->path + name.fileName().length() + 1, "octect"); + QByteArray baName = name.fileName().toUtf8(); + memset(th->path, 0, baName.length()+8); + memcpy(th->path, baName.constData(), baName.length()); + memcpy(th->path + baName.length() + 1, "octect", 6); sock = new QUdpSocket(this); sock->bind(); @@ -262,8 +264,9 @@ void QTftp::client_put(QString path, QString server) m_segsize = 512; m_timeout = 1000; struct tftp_header *th = (struct tftp_header *)buffer; - strcpy(th->path, name.fileName().toUtf8().constData()); - strcpy(th->path + name.fileName().length() + 1, "octect"); + QByteArray baName = name.fileName().toUtf8(); + memcpy(th->path, baName.constData(), baName.length()); + memcpy(th->path + baName.length() + 1, "octect", 6); sock = new QUdpSocket(this); sock->bind(); diff --git a/lib/qextserialport/qextserialenumerator_win.cpp b/lib/qextserialport/qextserialenumerator_win.cpp index fdd2f59b..1d97f4ff 100644 --- a/lib/qextserialport/qextserialenumerator_win.cpp +++ b/lib/qextserialport/qextserialenumerator_win.cpp @@ -121,7 +121,7 @@ static QString getRegKeyValue(HKEY key, LPCTSTR property) BYTE *buff = new BYTE[size]; QString result; if (::RegQueryValueEx(key, property, NULL, &type, buff, &size) == ERROR_SUCCESS) - result = QString::fromUtf16(reinterpret_cast(buff)); + result = QString::fromUtf16(reinterpret_cast(buff)); delete [] buff; return result; } @@ -145,7 +145,7 @@ static QString getDeviceRegistryProperty(HDEVINFO devInfoSet, PSP_DEVINFO_DATA d return QString(); BYTE *buff = new BYTE[buffSize]; ::SetupDiGetDeviceRegistryProperty(devInfoSet, devInfoData, property, NULL, buff, buffSize, NULL); - QString result = QString::fromUtf16(reinterpret_cast(buff)); + QString result = QString::fromUtf16(reinterpret_cast(buff)); delete [] buff; return result; } @@ -263,7 +263,7 @@ LRESULT QextSerialEnumeratorPrivate::onDeviceChanged(WPARAM wParam, LPARAM lPara if (pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr; // delimiters are different across APIs...change to backslash. ugh. - QString deviceID = QString::fromUtf16(reinterpret_cast(pDevInf->dbcc_name)); + QString deviceID = QString::fromUtf16(reinterpret_cast(pDevInf->dbcc_name)); deviceID = deviceID.toUpper().replace(QLatin1String("#"), QLatin1String("\\")); matchAndDispatchChangedDevice(deviceID, GUID_DEVINTERFACE_COMPORT, wParam); @@ -285,7 +285,7 @@ bool QextSerialEnumeratorPrivate::matchAndDispatchChangedDevice(const QString &d DWORD nSize = 0; TCHAR buf[MAX_PATH]; if (SetupDiGetDeviceInstanceId(devInfoSet, &spDevInfoData, buf, MAX_PATH, &nSize) - && deviceID.contains(QString::fromUtf16(reinterpret_cast(buf)))) { // we found a match + && deviceID.contains(QString::fromUtf16(reinterpret_cast(buf)))) { // we found a match rv = true; QextPortInfo info; info.productID = info.vendorID = info.revision = 0; diff --git a/lib/qtermwidget/TerminalDisplay.cpp b/lib/qtermwidget/TerminalDisplay.cpp index b97699fa..b679bbdd 100644 --- a/lib/qtermwidget/TerminalDisplay.cpp +++ b/lib/qtermwidget/TerminalDisplay.cpp @@ -1753,7 +1753,8 @@ void TerminalDisplay::paintFilters(QPainter &painter) { do { if (endColumn <= 0) break; - if (_image[loc(startColumn, line)].character > 0xffff) + uint64_t ucode = _image[loc(startColumn, line)].character; + if (ucode > 0xffff) break; if (QChar(_image[loc(startColumn, line)].character).isSpace()) break; diff --git a/lib/qtermwidget/util/CharWidth.cpp b/lib/qtermwidget/util/CharWidth.cpp index 715ac274..bb829ccc 100644 --- a/lib/qtermwidget/util/CharWidth.cpp +++ b/lib/qtermwidget/util/CharWidth.cpp @@ -14,7 +14,8 @@ void CharWidth::setFont(QFont font) { } int CharWidth::font_width(wchar_t ucs) { - if(ucs <= 0xffff) + uint64_t ucode = ucs; + if(ucode <= 0xffff) return fm->horizontalAdvance(QString(QChar(ucs)),1)/fm->horizontalAdvance("0",1); else return unicode_width(ucs); diff --git a/lib/qtkeychain/keychain_win.cpp b/lib/qtkeychain/keychain_win.cpp index 98dd34cb..fab3806a 100644 --- a/lib/qtkeychain/keychain_win.cpp +++ b/lib/qtkeychain/keychain_win.cpp @@ -81,7 +81,7 @@ void WritePasswordJobPrivate::scheduledStart() { } if (err == RPC_S_INVALID_BOUND) { const size_t maxTargetName = CRED_MAX_GENERIC_TARGET_NAME_LENGTH; - if (key.size() > maxTargetName) { + if (((size_t)key.size()) > maxTargetName) { q->emitFinishedWithError( OtherError, tr("Credential key exceeds maximum size of %1").arg(maxTargetName)); diff --git a/lib/qzmodem/qrecvzmodem.cpp b/lib/qzmodem/qrecvzmodem.cpp index 028035fd..5d35732f 100644 --- a/lib/qzmodem/qrecvzmodem.cpp +++ b/lib/qzmodem/qrecvzmodem.cpp @@ -798,14 +798,14 @@ int QRecvZmodem::rz_receive_file(struct zm_fileinfo *zi) { if (akt->pos == zi->bytes_received) { rz_write_string_to_file(zi, akt->data, akt->len); zi->bytes_received += akt->len; - qDebug("using saved out-of-sync-paket %lx, len %ld", akt->pos, - akt->len); + qDebug("using saved out-of-sync-paket %llx, len %lld", (uint64_t)akt->pos, + (uint64_t)akt->len); goto nxthdr; } next = akt->next; if (akt->pos < zi->bytes_received) { - qDebug("removing unneeded saved out-of-sync-paket %lx, len %ld", - akt->pos, akt->len); + qDebug("removing unneeded saved out-of-sync-paket %llx, len %lld", + (uint64_t)akt->pos, (uint64_t)akt->len); if (last) last->next = akt->next; else @@ -881,8 +881,8 @@ int QRecvZmodem::rz_receive_file(struct zm_fileinfo *zi) { if (neu) neu->data = (char *)malloc(bytes_in_block); if (neu && neu->data) { - qDebug("saving out-of-sync-block %lx, len %lu", pos, - (unsigned long)bytes_in_block); + qDebug("saving out-of-sync-block %llx, len %llu", (uint64_t)pos, + (uint64_t)bytes_in_block); memcpy(neu->data, secbuf, bytes_in_block); neu->pos = pos; neu->len = bytes_in_block; diff --git a/lib/sqlite/sqlite3.c b/lib/sqlite/sqlite3.c index eaa24a13..7b307b5b 100644 --- a/lib/sqlite/sqlite3.c +++ b/lib/sqlite/sqlite3.c @@ -34247,6 +34247,7 @@ SQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject); /* os_win.c */ SQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){ DWORD rc; BOOL bRc; + (void)bRc; assert( ppOut!=0 ); if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT; @@ -51209,6 +51210,7 @@ static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){ ** may now be invalid and should be unmapped. */ static int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){ + (void)iOff; #if SQLITE_MAX_MMAP_SIZE>0 winFile *pFd = (winFile*)fd; /* The underlying database file */