- Fix most GCC warnings in the backend/common code code.

* Most of them were just signedness issues. Hopefully I got everything right here.
* 3rd party stuff deliberately not touched.
This commit is contained in:
Mitchell Richters 2023-10-04 19:20:57 +11:00
parent 623e453d4d
commit 7e3a1dfb1e
13 changed files with 19 additions and 19 deletions

View file

@ -209,7 +209,7 @@ void C_DoCommand (const char *cmd, int keynum)
else
{
beg = cmd;
for (end = cmd+1; *end > ' ' || *end < 0; ++end)
for (end = cmd+1; *end > ' ' || (signed char)(*end) < 0; ++end)
;
}

View file

@ -91,8 +91,8 @@ bool FWHResFile::Open(LumpFilterInfo*)
uint32_t offset = LittleLong(directory[k*3]) * 4096;
uint32_t length = LittleLong(directory[k*3+1]);
if (length == 0) break;
char num[5];
snprintf(num, 5, "/%04d", k);
char num[6];
snprintf(num, 6, "/%04d", k);
std::string synthname = BaseName;
synthname += num;
Lumps[i].LumpNameSetup(synthname.c_str(), stringpool);

View file

@ -297,7 +297,7 @@ bool FZipFile::Open(LumpFilterInfo* filter, FileSystemMessageFunc Printf)
// at least one of the more common definition lumps must be present.
for (auto &p : filter->requiredPrefixes)
{
if (name.find(name0 + p) == 0 || name.rfind(p) == ptrdiff_t(name.length() - p.length()))
if (name.find(name0 + p) == 0 || name.rfind(p) == size_t(name.length() - p.length()))
{
foundspeciallump = true;
break;

View file

@ -173,7 +173,7 @@ public:
ptrdiff_t Read (void *buffer, ptrdiff_t len) override
{
int err;
int err = 0;
if (File == nullptr)
{

View file

@ -147,7 +147,7 @@ struct FileSystem::LumpRecord
{
std::string longName = LongName;
ptrdiff_t encodedResID = longName.find_last_of(".{");
if (resourceId == -1 && encodedResID != std::string::npos)
if (resourceId == -1 && (size_t)encodedResID != std::string::npos)
{
const char* p = LongName + encodedResID;
char* q;
@ -978,7 +978,7 @@ void FileSystem::MoveLumpsInFolder(const char *path)
int FileSystem::FindLump (const char *name, int *lastlump, bool anyns)
{
if (*lastlump >= FileInfo.size()) return -1;
if ((size_t)*lastlump >= FileInfo.size()) return -1;
union
{
char name8[8];

View file

@ -415,7 +415,7 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize, LumpFilterI
ptrdiff_t lastpos = -1;
std::string file;
std::string& LumpFilter = filter->dotFilter;
while ((len = LumpFilter.find_first_of('.', lastpos+1)) != LumpFilter.npos)
while (size_t(len = LumpFilter.find_first_of('.', lastpos+1)) != LumpFilter.npos)
{
max -= FilterLumps(std::string(LumpFilter, 0, len), lumps, lumpsize, max);
lastpos = len;

View file

@ -222,7 +222,7 @@ int32_t ANIM_LoadAnim(anim_t *anim, const uint8_t *buffer, size_t length)
if (memcmp(buffer, "LPF ", 4)) return -1;
length -= sizeof(lpfileheader)+128+768;
if (length < 0)
if ((signed)length < 0)
return -1;
anim->curlpnum = 0xffff;
@ -244,7 +244,7 @@ int32_t ANIM_LoadAnim(anim_t *anim, const uint8_t *buffer, size_t length)
lpheader.framesPerSecond = LittleShort(lpheader.framesPerSecond);
length -= lpheader.nLps * sizeof(lp_descriptor);
if (length < 0)
if ((signed)length < 0)
return -2;
buffer += sizeof(lpfileheader)+128;

View file

@ -59,7 +59,7 @@ FImageSource *QOIImage_TryCreate(FileReader &file, int lumpnum)
{
QOIHeader header;
if (file.GetLength() < (sizeof(header) + 8))
if ((size_t)file.GetLength() < (sizeof(header) + 8))
{
return nullptr;
}
@ -86,7 +86,7 @@ FQOITexture::FQOITexture(int lumpnum, QOIHeader& header)
LeftOffset = TopOffset = 0;
Width = header.width;
Height = header.height;
if (header.channels == 3) bMasked = bTranslucent = false;
if (header.channels == 3) bMasked = (bTranslucent = false);
}
PalettedPixels FQOITexture::CreatePalettedPixels(int conversion, int frame)

View file

@ -1632,7 +1632,7 @@ void FTextureManager::Listaliases()
void FTextureManager::SetLinkedTexture(int lump, FGameTexture* tex)
{
if ((size_t)lump < fileSystem.GetNumEntries())
if (lump < fileSystem.GetNumEntries())
{
linkedMap.Insert(lump, tex);
}
@ -1646,7 +1646,7 @@ void FTextureManager::SetLinkedTexture(int lump, FGameTexture* tex)
FGameTexture* FTextureManager::GetLinkedTexture(int lump)
{
if ((size_t)lump < fileSystem.GetNumEntries())
if (lump < fileSystem.GetNumEntries())
{
auto check = linkedMap.CheckKey(lump);
if (check) return *check;

View file

@ -842,12 +842,12 @@ void FString::StripLeftRight ()
if (max == 0) return;
for (i = 0; i < max; ++i)
{
if (Chars[i] < 0 || !isspace((unsigned char)Chars[i]))
if ((signed char)Chars[i] < 0 || !isspace((unsigned char)Chars[i]))
break;
}
for (j = max - 1; j >= i; --j)
{
if (Chars[j] < 0 || !isspace((unsigned char)Chars[j]))
if ((signed char)Chars[j] < 0 || !isspace((unsigned char)Chars[j]))
break;
}
if (i == 0 && j == max - 1)

View file

@ -1285,7 +1285,7 @@ int FindBestSector(const DVector3& pos)
int isAwayFromWall(DCoreActor* ac, double delta)
{
sectortype* s1;
sectortype* s1 = nullptr;
updatesector(ac->spr.pos + DVector2(delta, delta), &s1);
if (s1 == ac->sector())

View file

@ -36,7 +36,7 @@ class GameInput
// Input received from the OS.
float joyAxes[NUM_JOYAXIS];
FVector2 mouseInput;
FVector2 mouseInput;
// Internal variables when generating a packet.
InputPacket inputBuffer;

View file

@ -814,7 +814,7 @@ void tspritetype_setSpritePic(tspritetype* targ, DCoreActor* self, unsigned z)
{
targ->setspritetexture(spriteset[z]);
}
else if (z == ~0)
else if ((signed)z == ~0)
{
targ->setspritetexture(self->dispictex);
}