Skip to content

Commit

Permalink
Fix these warnings:
Browse files Browse the repository at this point in the history
rc/mid.cpp: In member function ‘virtual void CmidPlayer::rewind(int)’:
src/mid.cpp:995:46: warning: comparison of integer expressions of different signedness: ‘long unsigned int’ and ‘long int’ [-Wsign-compare]
  995 |                     if (track[curtrack].tend > flen) // no music after end of file
      |                         ~~~~~~~~~~~~~~~~~~~~~^~~~~~
src/mid.cpp:1013:57: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘long int’ [-Wsign-compare]
 1013 |                     strnlen((char *)data + i, flen - i) < flen - i)
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
src/mid.cpp:1017:57: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘long int’ [-Wsign-compare]
 1017 |                     strnlen((char *)data + i, flen - i) < flen - i)
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
src/mid.cpp:1021:57: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘long int’ [-Wsign-compare]
 1021 |                     strnlen((char *)data + i, flen - i) < flen - i)
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
src/mid.cpp:1108:62: warning: comparison of integer expressions of different signedness: ‘long unsigned int’ and ‘long int’ [-Wsign-compare]
 1108 |                 while (datalook(sierra_pos-2) != 0xff && pos < flen)
      |                                                          ~~~~^~~~~~
  • Loading branch information
mywave82 committed Dec 17, 2022
1 parent 777bfe8 commit 8b5faca
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 8b5faca

Please sign in to comment.