Browse Source

Fix warnings: `-Wsign-compare`, `-Wnarrowing`

pull/3713/head
Gleb Mazovetskiy 4 years ago
parent
commit
a4bc8fea7d
  1. 4
      Source/control.cpp
  2. 6
      Source/mpq/mpq_sdl_rwops.cpp
  3. 6
      Source/utils/language.cpp

4
Source/control.cpp

@ -1167,9 +1167,7 @@ void control_type_message()
return;
talkflag = true;
int x = PANEL_LEFT + 200;
int y = PANEL_Y + 22;
SDL_Rect rect = { x, y, 250, 39 };
SDL_Rect rect = MakeSdlRect(PANEL_LEFT + 200, PANEL_Y + 22, 250, 39);
SDL_SetTextInputRect(&rect);
TalkMessage[0] = '\0';
for (bool &talkButtonDown : TalkButtonsDown) {

6
Source/mpq/mpq_sdl_rwops.cpp

@ -69,10 +69,10 @@ static OffsetType MpqFileRwSeek(struct SDL_RWops *context, OffsetType offset, in
return -1;
}
if (newPosition == data.position)
if (newPosition == static_cast<OffsetType>(data.position))
return newPosition;
if (newPosition > data.size) {
if (newPosition > static_cast<OffsetType>(data.size)) {
SDL_SetError("MpqFileRwSeek beyond EOF (%d > %u)", static_cast<int>(newPosition), data.size);
return -1;
}
@ -94,7 +94,7 @@ static SizeType MpqFileRwRead(struct SDL_RWops *context, void *ptr, SizeType siz
{
Data &data = *GetData(context);
const SizeType totalSize = size * maxnum;
SizeType remainingSize = totalSize;
uint32_t remainingSize = totalSize;
auto *out = static_cast<uint8_t *>(ptr);

6
Source/utils/language.cpp

@ -222,7 +222,7 @@ bool ReadEntry(SDL_RWops *rw, MoEntry *e, std::vector<char> &result)
return false;
result.resize(e->length + 1);
result.back() = '\0';
return (SDL_RWread(rw, result.data(), sizeof(char), e->length) == e->length);
return static_cast<uint32_t>(SDL_RWread(rw, result.data(), sizeof(char), e->length)) == e->length;
}
} // namespace
@ -329,7 +329,7 @@ void LanguageInitialize()
return;
}
// FIXME: Endianness.
if (SDL_RWread(rw, src.get(), sizeof(MoEntry), head.nbMappings) != head.nbMappings) {
if (static_cast<uint32_t>(SDL_RWread(rw, src.get(), sizeof(MoEntry), head.nbMappings)) != head.nbMappings) {
SDL_RWclose(rw);
return;
}
@ -341,7 +341,7 @@ void LanguageInitialize()
return;
}
// FIXME: Endianness.
if (SDL_RWread(rw, dst.get(), sizeof(MoEntry), head.nbMappings) != head.nbMappings) {
if (static_cast<uint32_t>(SDL_RWread(rw, dst.get(), sizeof(MoEntry), head.nbMappings)) != head.nbMappings) {
SDL_RWclose(rw);
return;
}

Loading…
Cancel
Save