Skip to content

Commit

Permalink
Merge pull request adplug#154 from mywave82/mid-Wsign-compare
Browse files Browse the repository at this point in the history
Fix for mid-Wsign-compare and convert some additional variables from signed into unsigned
  • Loading branch information
mywave82 authored Feb 26, 2023
2 parents 2bb5ebe + 8b5faca commit 67afaea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/mid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ CmidPlayer::CmidPlayer(Copl *newopl)
{
}

unsigned char CmidPlayer::datalook(long pos)
unsigned char CmidPlayer::datalook(unsigned long pos)
{
if (pos<0 || pos >= flen) return(0);
if (pos >= flen) return(0);
return(data[pos]);
}

Expand Down Expand Up @@ -1009,15 +1009,15 @@ void CmidPlayer::rewind(int subsong)
if (i) msqtr = 1000000L / i * deltas;

i=getnexti(2);
if (i > 0 && i < flen &&
if (i > 0 && (unsigned long)i < flen &&
strnlen((char *)data + i, flen - i) < flen - i)
title = (char *)data + i;
i=getnexti(2);
if (i > 0 && i < flen &&
if (i > 0 && (unsigned long)i < flen &&
strnlen((char *)data + i, flen - i) < flen - i)
author = (char *)data + i;
i=getnexti(2);
if (i > 0 && i < flen &&
if (i > 0 && (unsigned long)i < flen &&
strnlen((char *)data + i, flen - i) < flen - i)
remarks = (char *)data + i;

Expand Down
4 changes: 2 additions & 2 deletions src/mid.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CmidPlayer: public CPlayer
};

char *author,*title,*remarks,emptystr;
long flen;
unsigned long flen;
unsigned long pos;
unsigned long sierra_pos; //sierras gotta be special.. :>
int subsongs;
Expand Down Expand Up @@ -98,7 +98,7 @@ class CmidPlayer: public CPlayer
private:
bool load_sierra_ins(const std::string &fname, const CFileProvider &fp);
void midiprintf(const char *format, ...);
unsigned char datalook(long pos);
unsigned char datalook(unsigned long pos);
unsigned long getnexti(unsigned long num);
unsigned long getnext(unsigned long num);
void readString(char *dst, unsigned long num);
Expand Down

0 comments on commit 67afaea

Please sign in to comment.