diff --git a/src/addrman.h b/src/addrman.h --- a/src/addrman.h +++ b/src/addrman.h @@ -55,7 +55,7 @@ template inline void SerializationOp(Stream &s, Operation ser_action) { - READWRITE(*(CAddress *)this); + READWRITE(*static_cast(this)); READWRITE(source); READWRITE(nLastSuccess); READWRITE(nAttempts); diff --git a/src/core_read.cpp b/src/core_read.cpp --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -31,16 +31,16 @@ continue; } - const char *name = GetOpName((opcodetype)op); + const char *name = GetOpName(static_cast(op)); if (strcmp(name, "OP_UNKNOWN") == 0) { continue; } std::string strName(name); - mapOpNames[strName] = (opcodetype)op; + mapOpNames[strName] = static_cast(op); // Convenience: OP_ADD and just ADD are both recognized: boost::algorithm::replace_first(strName, "OP_", ""); - mapOpNames[strName] = (opcodetype)op; + mapOpNames[strName] = static_cast(op); } } diff --git a/src/httpserver.cpp b/src/httpserver.cpp --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -513,7 +513,7 @@ static void httpevent_callback_fn(evutil_socket_t, short, void *data) { // Static handler: simply call inner handler - HTTPEvent *self = ((HTTPEvent *)data); + HTTPEvent *self = static_cast(data); self->handler(); if (self->deleteWhenTriggered) delete self; } diff --git a/src/net.cpp b/src/net.cpp --- a/src/net.cpp +++ b/src/net.cpp @@ -2109,7 +2109,8 @@ return; } if (!pszDest) { - if (IsLocal(addrConnect) || FindNode((CNetAddr)addrConnect) || + if (IsLocal(addrConnect) || + FindNode(static_cast(addrConnect)) || IsBanned(addrConnect) || FindNode(addrConnect.ToStringIPPort())) { return; } diff --git a/src/netaddress.cpp b/src/netaddress.cpp --- a/src/netaddress.cpp +++ b/src/netaddress.cpp @@ -513,7 +513,8 @@ } bool operator==(const CService &a, const CService &b) { - return (CNetAddr)a == (CNetAddr)b && a.port == b.port; + return static_cast(a) == static_cast(b) && + a.port == b.port; } bool operator<(const CService &a, const CService &b) { diff --git a/src/primitives/block.h b/src/primitives/block.h --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -70,14 +70,14 @@ CBlock(const CBlockHeader &header) { SetNull(); - *((CBlockHeader *)this) = header; + *(static_cast(this)) = header; } ADD_SERIALIZE_METHODS; template inline void SerializationOp(Stream &s, Operation ser_action) { - READWRITE(*(CBlockHeader *)this); + READWRITE(*static_cast(this)); READWRITE(vtx); } diff --git a/src/protocol.h b/src/protocol.h --- a/src/protocol.h +++ b/src/protocol.h @@ -395,8 +395,8 @@ READWRITE(nTime); uint64_t nServicesInt = nServices; READWRITE(nServicesInt); - nServices = (ServiceFlags)nServicesInt; - READWRITE(*(CService *)this); + nServices = static_cast(nServicesInt); + READWRITE(*static_cast(this)); } // TODO: make private (improves encapsulation) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -793,7 +793,7 @@ WinShutdownMonitor::registerShutdownBlockReason( QObject::tr("%1 didn't yet exit safely...") .arg(QObject::tr(PACKAGE_NAME)), - (HWND)app.getMainWinId()); + static_cast(app.getMainWinId())); #endif app.exec(); app.requestShutdown(config); diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -649,7 +649,7 @@ #else // Note: On Mac, the dock icon is used to provide the tray's functionality. MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); - dockIconHandler->setMainWindow((QMainWindow *)this); + dockIconHandler->setMainWindow(static_cast(this)); trayIconMenu = dockIconHandler->dockMenu(); #endif @@ -978,14 +978,15 @@ buttons = QMessageBox::Ok; showNormalIfMinimized(); - QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, - buttons, this); + QMessageBox mBox(static_cast(nMBoxIcon), strTitle, + message, buttons, this); int r = mBox.exec(); if (ret != nullptr) { *ret = r == QMessageBox::Ok; } } else - notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message); + notificator->notify(static_cast(nNotifyIcon), + strTitle, message); } void BitcoinGUI::changeEvent(QEvent *e) { diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -163,9 +163,9 @@ ui->radioTreeMode->click(); if (settings.contains("nCoinControlSortColumn") && settings.contains("nCoinControlSortOrder")) - sortView( - settings.value("nCoinControlSortColumn").toInt(), - ((Qt::SortOrder)settings.value("nCoinControlSortOrder").toInt())); + sortView(settings.value("nCoinControlSortColumn").toInt(), + (static_cast( + settings.value("nCoinControlSortOrder").toInt()))); } CoinControlDialog::~CoinControlDialog() { @@ -467,7 +467,8 @@ nPayAmount += amount; if (amount > Amount::zero()) { - CTxOut txout(Amount(amount), (CScript)std::vector(24, 0)); + CTxOut txout(amount, + static_cast(std::vector(24, 0))); txDummy.vout.push_back(txout); if (txout.IsDust(dustRelayFee)) { fDust = true; @@ -556,7 +557,8 @@ // Never create dust outputs; if we would, just add the dust to the // fee. if (nChange > Amount::zero() && nChange < MIN_CHANGE) { - CTxOut txout(nChange, (CScript)std::vector(24, 0)); + CTxOut txout(nChange, + static_cast(std::vector(24, 0))); if (txout.IsDust(dustRelayFee)) { // dust-change will be raised until no dust if (CoinControlDialog::fSubtractFeeFromAmount) { diff --git a/src/qt/coincontroltreewidget.cpp b/src/qt/coincontroltreewidget.cpp --- a/src/qt/coincontroltreewidget.cpp +++ b/src/qt/coincontroltreewidget.cpp @@ -23,7 +23,7 @@ { event->ignore(); CoinControlDialog *coinControlDialog = - (CoinControlDialog *)this->parentWidget(); + static_cast(this->parentWidget()); coinControlDialog->done(QDialog::Accepted); } else { this->QTreeWidget::keyPressEvent(event); diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -384,7 +384,7 @@ SEND_CONFIRM_DELAY, this); confirmationDialog.exec(); QMessageBox::StandardButton retval = - (QMessageBox::StandardButton)confirmationDialog.result(); + static_cast(confirmationDialog.result()); if (retval != QMessageBox::Yes) { fNewRecipientAllowed = true; diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -38,7 +38,8 @@ float devicePixelRatio = 1.0; #if QT_VERSION > 0x050100 devicePixelRatio = - ((QGuiApplication *)QCoreApplication::instance())->devicePixelRatio(); + static_cast(QCoreApplication::instance()) + ->devicePixelRatio(); #endif // define text to place diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -329,8 +329,8 @@ } transactionProxyModel->setWatchOnlyFilter( - (TransactionFilterProxy::WatchOnlyFilter)watchOnlyWidget->itemData(idx) - .toInt()); + static_cast( + watchOnlyWidget->itemData(idx).toInt())); } void TransactionView::changedPrefix(const QString &prefix) { diff --git a/src/qt/winshutdownmonitor.cpp b/src/qt/winshutdownmonitor.cpp --- a/src/qt/winshutdownmonitor.cpp +++ b/src/qt/winshutdownmonitor.cpp @@ -56,8 +56,9 @@ void WinShutdownMonitor::registerShutdownBlockReason(const QString &strReason, const HWND &mainWinId) { typedef BOOL(WINAPI * PSHUTDOWNBRCREATE)(HWND, LPCWSTR); - PSHUTDOWNBRCREATE shutdownBRCreate = (PSHUTDOWNBRCREATE)GetProcAddress( - GetModuleHandleA("User32.dll"), "ShutdownBlockReasonCreate"); + PSHUTDOWNBRCREATE shutdownBRCreate = + static_cast(GetProcAddress( + GetModuleHandleA("User32.dll"), "ShutdownBlockReasonCreate")); if (shutdownBRCreate == nullptr) { qWarning() << "registerShutdownBlockReason: GetProcAddress for " "ShutdownBlockReasonCreate failed"; diff --git a/src/script/script.h b/src/script/script.h --- a/src/script/script.h +++ b/src/script/script.h @@ -558,7 +558,7 @@ pc += nSize; } - opcodeRet = (opcodetype)opcode; + opcodeRet = static_cast(opcode); return true; } diff --git a/src/test/versionbits_tests.cpp b/src/test/versionbits_tests.cpp --- a/src/test/versionbits_tests.cpp +++ b/src/test/versionbits_tests.cpp @@ -364,8 +364,8 @@ const auto chainParams = CreateChainParams(CBaseChainParams::MAIN); const Consensus::Params &mainnetParams = chainParams->GetConsensus(); for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) { - uint32_t bitmask = - VersionBitsMask(mainnetParams, (Consensus::DeploymentPos)i); + uint32_t bitmask = VersionBitsMask( + mainnetParams, static_cast(i)); // Make sure that no deployment tries to set an invalid bit. BOOST_CHECK_EQUAL(bitmask & ~(uint32_t)VERSIONBITS_TOP_MASK, bitmask); @@ -377,7 +377,8 @@ // earlier to avoid overlap.) for (int j = i + 1; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; j++) { - if (VersionBitsMask(mainnetParams, (Consensus::DeploymentPos)j) == + if (VersionBitsMask(mainnetParams, + static_cast(j)) == bitmask) { BOOST_CHECK(mainnetParams.vDeployments[j].nStartTime > mainnetParams.vDeployments[i].nTimeout || diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -139,7 +139,7 @@ } void TorControlConnection::readcb(struct bufferevent *bev, void *ctx) { - TorControlConnection *self = (TorControlConnection *)ctx; + TorControlConnection *self = static_cast(ctx); struct evbuffer *input = bufferevent_get_input(bev); size_t n_read_out = 0; char *line; @@ -190,7 +190,7 @@ void TorControlConnection::eventcb(struct bufferevent *bev, short what, void *ctx) { - TorControlConnection *self = (TorControlConnection *)ctx; + TorControlConnection *self = static_cast(ctx); if (what & BEV_EVENT_CONNECTED) { LogPrint(BCLog::TOR, "tor: Successfully connected!\n"); self->connected(*self); @@ -766,7 +766,7 @@ } void TorController::reconnect_cb(evutil_socket_t fd, short what, void *arg) { - TorController *self = (TorController *)arg; + TorController *self = static_cast(arg); self->Reconnect(); } diff --git a/src/txdb.h b/src/txdb.h --- a/src/txdb.h +++ b/src/txdb.h @@ -49,7 +49,7 @@ template inline void SerializationOp(Stream &s, Operation ser_action) { - READWRITE(*(CDiskBlockPos *)this); + READWRITE(*static_cast(this)); READWRITE(VARINT(nTxOffset)); } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -376,7 +376,7 @@ } } - READWRITE(*(CMerkleTx *)this); + READWRITE(*static_cast(this)); //!< Used to be vtxPrev std::vector vUnused; READWRITE(vUnused);