- 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 committed by Christoph Oelckers
parent 526db7f8b0
commit 0c13d4fe3a
13 changed files with 19 additions and 19 deletions

View file

@ -209,7 +209,7 @@ void C_DoCommand (const char *cmd, int keynum)
else else
{ {
beg = cmd; 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 offset = LittleLong(directory[k*3]) * 4096;
uint32_t length = LittleLong(directory[k*3+1]); uint32_t length = LittleLong(directory[k*3+1]);
if (length == 0) break; if (length == 0) break;
char num[5]; char num[6];
snprintf(num, 5, "/%04d", k); snprintf(num, 6, "/%04d", k);
std::string synthname = BaseName; std::string synthname = BaseName;
synthname += num; synthname += num;
Lumps[i].LumpNameSetup(synthname.c_str(), stringpool); 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. // at least one of the more common definition lumps must be present.
for (auto &p : filter->requiredPrefixes) 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; foundspeciallump = true;
break; break;

View file

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

View file

@ -147,7 +147,7 @@ struct FileSystem::LumpRecord
{ {
std::string longName = LongName; std::string longName = LongName;
ptrdiff_t encodedResID = longName.find_last_of(".{"); 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; const char* p = LongName + encodedResID;
char* q; char* q;
@ -978,7 +978,7 @@ void FileSystem::MoveLumpsInFolder(const char *path)
int FileSystem::FindLump (const char *name, int *lastlump, bool anyns) 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 union
{ {
char name8[8]; char name8[8];

View file

@ -415,7 +415,7 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize, LumpFilterI
ptrdiff_t lastpos = -1; ptrdiff_t lastpos = -1;
std::string file; std::string file;
std::string& LumpFilter = filter->dotFilter; 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); max -= FilterLumps(std::string(LumpFilter, 0, len), lumps, lumpsize, max);
lastpos = len; 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; if (memcmp(buffer, "LPF ", 4)) return -1;
length -= sizeof(lpfileheader)+128+768; length -= sizeof(lpfileheader)+128+768;
if (length < 0) if ((signed)length < 0)
return -1; return -1;
anim->curlpnum = 0xffff; 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); lpheader.framesPerSecond = LittleShort(lpheader.framesPerSecond);
length -= lpheader.nLps * sizeof(lp_descriptor); length -= lpheader.nLps * sizeof(lp_descriptor);
if (length < 0) if ((signed)length < 0)
return -2; return -2;
buffer += sizeof(lpfileheader)+128; buffer += sizeof(lpfileheader)+128;

View file

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

View file

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

View file

@ -842,12 +842,12 @@ void FString::StripLeftRight ()
if (max == 0) return; if (max == 0) return;
for (i = 0; i < max; ++i) 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; break;
} }
for (j = max - 1; j >= i; --j) 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; break;
} }
if (i == 0 && j == max - 1) if (i == 0 && j == max - 1)

View file

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

View file

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