1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-20 19:02:41 +01:00

Codechange: Replace C-style casts to size_t with static_cast. (#12455)

* Codechange: Replace C-style casts to size_t with static_cast.

This touches only simple value-type casts.

* Codechange: Replace static_cast<size_t>(-1) with SIZE_MAX

Co-authored-by: Rubidium <rubidium@openttd.org>
This commit is contained in:
Peter Nelson
2024-04-19 20:34:36 +01:00
committed by GitHub
parent 6ee31a2a22
commit a28ab8cac2
24 changed files with 38 additions and 38 deletions

View File

@@ -442,7 +442,7 @@ static bool GunzipFile(const ContentInfo *ci)
if (errnum != 0 && errnum != Z_STREAM_END) ret = false;
break;
}
if (read < 0 || (size_t)read != fwrite(buff, 1, read, fout)) {
if (read < 0 || static_cast<size_t>(read) != fwrite(buff, 1, read, fout)) {
/* If gzread() returns -1, there was an error in archive */
ret = false;
break;
@@ -496,7 +496,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_CONTENT(Packet &p)
} else {
/* We have a file opened, thus are downloading internal content */
size_t toRead = p.RemainingBytesToTransfer();
if (toRead != 0 && (size_t)p.TransferOut(TransferOutFWrite, this->curFile) != toRead) {
if (toRead != 0 && static_cast<size_t>(p.TransferOut(TransferOutFWrite, this->curFile)) != toRead) {
CloseWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD);
ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD, STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD_FILE_NOT_WRITABLE, WL_ERROR);
this->CloseConnection();