Skip to content

Commit

Permalink
misc warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Feb 3, 2021
1 parent 4d574e2 commit 37223b0
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/libmodplug/fastmix.c
Expand Up @@ -1434,13 +1434,13 @@ UINT CSoundFile_CreateStereoMix(CSoundFile *_this, int count)
{
const LPMIXINTERFACE *pMixFuncTable;
MODCHANNEL * const pChannel = &_this->Chn[_this->ChnMix[nChn]];
UINT nFlags, nMasterCh;
UINT nFlags;//, nMasterCh
LONG nSmpCount;
int nsamples;
int *pbuffer;

if (!pChannel->pCurrentSample) continue;
nMasterCh = (_this->ChnMix[nChn] < _this->m_nChannels) ? _this->ChnMix[nChn]+1 : pChannel->nMasterChn;
//nMasterCh = (_this->ChnMix[nChn] < _this->m_nChannels) ? _this->ChnMix[nChn]+1 : pChannel->nMasterChn;
pOfsR = &_this->gnDryROfsVol;
pOfsL = &_this->gnDryLOfsVol;
nFlags = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/libmodplug/load_669.c
Expand Up @@ -35,9 +35,9 @@ typedef struct tagSAMPLE669

static DWORD lengthArrayToDWORD(const BYTE length[4]) {
DWORD len = (length[3] << 24) +
(length[2] << 16) +
(length[1] << 8) +
(length[0]);
(length[2] << 16) +
(length[1] << 8) +
(length[0]);

return(len);
}
Expand All @@ -46,14 +46,14 @@ static DWORD lengthArrayToDWORD(const BYTE length[4]) {
BOOL CSoundFile_Read669(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLength)
//---------------------------------------------------------------
{
BOOL b669Ext;
// BOOL b669Ext;
const FILEHEADER669 *pfh = (const FILEHEADER669 *)lpStream;
const SAMPLE669 *psmp = (const SAMPLE669 *)(lpStream + 0x1F1);
DWORD dwMemPos = 0;

if ((!lpStream) || (dwMemLength < sizeof(FILEHEADER669))) return FALSE;
if ((bswapLE16(pfh->sig) != 0x6669) && (bswapLE16(pfh->sig) != 0x4E4A)) return FALSE;
b669Ext = (bswapLE16(pfh->sig) == 0x4E4A) ? TRUE : FALSE;
// b669Ext = (bswapLE16(pfh->sig) == 0x4E4A) ? TRUE : FALSE;
if ((!pfh->samples) || (pfh->samples > 64) || (pfh->restartpos >= 128)
|| (!pfh->patterns) || (pfh->patterns > 128)) return FALSE;
DWORD donttouchme = 0x1F1 + pfh->samples * sizeof(SAMPLE669) + pfh->patterns * 0x600;
Expand Down
27 changes: 14 additions & 13 deletions src/libmodplug/load_abc.c
Expand Up @@ -714,7 +714,7 @@ static ABCTRACK *abc_locate_track(ABCHANDLE *h, const char *voice, int pos)
char vc[21];
int i, trans=0, voiceno=0, instrno = 1, channo = 0;
for( ; *voice == ' '; voice++ ) ; // skip leading spaces
for( i=0; i+1 < sizeof(vc) && *voice && *voice != ']' && *voice != '%' && !SDL_isspace(*voice); voice++ ) // can work with inline voice instructions
for( i=0; i+1 < (int) sizeof(vc) && *voice && *voice != ']' && *voice != '%' && !SDL_isspace(*voice); voice++ ) // can work with inline voice instructions
vc[i++] = *voice;
vc[i] = '\0';
prev = NULL;
Expand Down Expand Up @@ -1384,7 +1384,8 @@ static void abc_add_chord(const char *p, ABCHANDLE *h, ABCTRACK *tp, uint32_t tr
break;
}
d[chordbase] = d[chordnote];
for( i=0; i < sizeof(s) - 1 && p[i] && p[i] != '"' && p[i] != '/' && p[i] != '(' && p[i] != ')' && p[i] != ' '; i++ ) s[i] = p[i];
for( i=0; i < (int)sizeof(s) - 1 && p[i] && p[i] != '"' && p[i] != '/' && p[i] != '(' && p[i] != ')' && p[i] != ' '; i++ )
s[i] = p[i];
s[i] = '\0';
p = &p[i];
if( *p=='/' ) {
Expand Down Expand Up @@ -1718,13 +1719,13 @@ static void abc_set_parts(char **d, char *p)
q = (char *)_mm_calloc(h, size + 1, sizeof(char)); // enough storage for the worst case
// now copy bytes from p to *d, taking parens and digits in account
j = 0;
for( i=0; p[i] && p[i] != '%' && j < size && i < size; i++ ) {
for( i=0; p[i] && p[i] != '%' && j < size && i < (int)size; i++ ) {
if( SDL_isdigit(p[i]) || IsUpper(p[i]) || p[i] == '(' || p[i] == ')' ) {
if( p[i] == ')' ) {
for( n=j; n > 0 && q[n-1] != '('; n-- ) ; // find open paren in q
// q[n+1] to q[j] contains the substring that must be repeated
if( n > 0 ) {
for( k = n; k<j; k++ ) q[k-1] = q[k]; // shift to the left...
for( k = n; k<(int)j; k++ ) q[k-1] = q[k]; // shift to the left...
j--;
}
else {
Expand Down Expand Up @@ -1759,10 +1760,10 @@ static void abc_set_parts(char **d, char *p)
}
q[j] = '\0';
// remove any left over parens
for( i=0; i<j; i++ ) {
for( i=0; i<(int)j; i++ ) {
if( q[i] == '(' ) {
abc_message("Warning: Unbalanced left parens in P: definition %s",p);
for( k=i; k<j; k++ ) q[k] = q[k+1];
for( k=i; k<(int)j; k++ ) q[k] = q[k+1];
j--;
}
}
Expand Down Expand Up @@ -2872,11 +2873,11 @@ static int abc_MIDI_drum(const char *p, ABCHANDLE *h)
for( q = h->drum; *p && !SDL_isspace(*p); p++ ) {
if( !SDL_strchr("dz0123456789",*p) ) break;
*q++ = *p; len++;
if( !SDL_isdigit(*p) && len < sizeof(h->drum)-1 ) {
if( !SDL_isdigit(*p) && len < (int)sizeof(h->drum)-1 ) {
if( !SDL_isdigit(p[1]) ) { *q++ = '1'; len ++; }
n++; // count the silences too....
}
if (len >= sizeof(h->drum)-1) {
if (len >= (int)sizeof(h->drum)-1) {
// consume the rest of the input
// definitely enough "drum last state" stored.
while ( *p && !SDL_isspace(*p) ) p++;
Expand Down Expand Up @@ -2926,8 +2927,8 @@ static int abc_MIDI_gchord(const char *p, ABCHANDLE *h)
for( q = h->gchord; *p && !SDL_isspace(*p); p++ ) {
if( !SDL_strchr("fbcz0123456789ghijGHIJ",*p) ) break;
*q++ = *p; len++;
if( !SDL_isdigit(*p) && len < sizeof(h->gchord)-1 && !SDL_isdigit(p[1]) ) { *q++ = '1'; len ++; }
if (len >= sizeof(h->gchord)-1) {
if( !SDL_isdigit(*p) && len < (int)sizeof(h->gchord)-1 && !SDL_isdigit(p[1]) ) { *q++ = '1'; len ++; }
if (len >= (int)sizeof(h->gchord)-1) {
// consume the rest of the input
// definitely enough "drum last state" stored.
while ( *p && !SDL_isspace(*p) ) p++;
Expand Down Expand Up @@ -2973,8 +2974,8 @@ static void abc_metric_gchord(ABCHANDLE *h, int mlen, int mdiv)

if( mdiv == 8 ) dest = mlen*2;
else dest = mlen*4;
if (dest >= sizeof(h->gchord))
dest = sizeof(h->gchord) - 1;
if (dest >= (int)sizeof(h->gchord))
dest = (int)sizeof(h->gchord) - 1;
h->gchord[dest] = '\0';
}
break;
Expand Down Expand Up @@ -3806,7 +3807,7 @@ BOOL CSoundFile_ReadABC(CSoundFile *_this, const uint8_t *lpStream, DWORD dwMemL
if( !SDL_strncmp(p,"m:",2) ) {
if( abcstate != INSKIPFORX ) {
char *pm = p;
if (mmstack[mmsp]->pos < dwMemLength) {
if (mmstack[mmsp]->pos < (LONG)dwMemLength) {
pm = abc_continuated(h, mmstack[mmsp], p);
abc_new_macro(h, pm+2);
}
Expand Down
6 changes: 2 additions & 4 deletions src/libmodplug/load_ams.c
Expand Up @@ -34,15 +34,13 @@ typedef struct AMSSAMPLEHEADER
BYTE infobyte;
} AMSSAMPLEHEADER;


#pragma pack()



BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
//-----------------------------------------------------------
{
BYTE pkinf[MAX_SAMPLES];
// BYTE pkinf[MAX_SAMPLES];
AMSFILEHEADER *pfh = (AMSFILEHEADER *)lpStream;
DWORD dwMemPos;
UINT tmp, tmp2;
Expand Down Expand Up @@ -75,7 +73,7 @@ BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
pins->nFineTune = MOD2XMFineTune(psh->finetune_and_pan & 0x0F);
pins->uFlags = (psh->infobyte & 0x80) ? CHN_16BIT : 0;
if ((pins->nLoopEnd <= pins->nLength) && (pins->nLoopStart+4 <= pins->nLoopEnd)) pins->uFlags |= CHN_LOOP;
pkinf[nSmp] = psh->infobyte;
// pkinf[nSmp] = psh->infobyte;
}
// Read Song Name
tmp = lpStream[dwMemPos++];
Expand Down
27 changes: 12 additions & 15 deletions src/libmodplug/load_it.c
Expand Up @@ -142,7 +142,7 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
DWORD inspos[MAX_INSTRUMENTS];
DWORD smppos[MAX_SAMPLES];
DWORD patpos[MAX_PATTERNS];
BYTE chnmask[64], channels_used[64];
BYTE chnmask[64];//, channels_used[64]
MODCOMMAND lastvalue[64];
UINT j;

Expand Down Expand Up @@ -206,9 +206,8 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
if (inspossize > MAX_INSTRUMENTS) inspossize = MAX_INSTRUMENTS;
inspossize <<= 2;
SDL_memcpy(inspos, lpStream+dwMemPos, inspossize);
for (j=0; j < (inspossize>>2); j++)
{
inspos[j] = bswapLE32(inspos[j]);
for (j=0; j < (inspossize>>2); j++) {
inspos[j] = bswapLE32(inspos[j]);
}
dwMemPos += pifh.insnum * 4;
// Reading Samples Offsets
Expand All @@ -217,9 +216,8 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
if (smppossize > MAX_SAMPLES) smppossize = MAX_SAMPLES;
smppossize <<= 2;
SDL_memcpy(smppos, lpStream+dwMemPos, smppossize);
for (j=0; j < (smppossize>>2); j++)
{
smppos[j] = bswapLE32(smppos[j]);
for (j=0; j < (smppossize>>2); j++) {
smppos[j] = bswapLE32(smppos[j]);
}
dwMemPos += pifh.smpnum * 4;
// Reading Patterns Offsets
Expand All @@ -228,9 +226,8 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
if (patpossize > MAX_PATTERNS) patpossize = MAX_PATTERNS;
patpossize <<= 2;
SDL_memcpy(patpos, lpStream+dwMemPos, patpossize);
for (j=0; j < (patpossize>>2); j++)
{
patpos[j] = bswapLE32(patpos[j]);
for (j=0; j < (patpossize>>2); j++) {
patpos[j] = bswapLE32(patpos[j]);
}
dwMemPos += pifh.patnum * 4;
// Reading IT Extra Info
Expand Down Expand Up @@ -478,7 +475,7 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
if (note < 0x80) note++;
m[ch].note = note;
lastvalue[ch].note = note;
channels_used[ch] = TRUE;
// channels_used[ch] = TRUE;
}
}
if (chnmask[ch] & 2)
Expand Down Expand Up @@ -596,7 +593,7 @@ void ITUnpack8Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dwM
{
signed char *pDst = pSample;
LPBYTE pSrc = lpMemFile;
DWORD wHdr = 0;
// DWORD wHdr = 0;
DWORD wCount = 0;
DWORD bitbuf = 0;
UINT bitnum = 0;
Expand All @@ -607,7 +604,7 @@ void ITUnpack8Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dwM
if (!wCount)
{
wCount = 0x8000;
wHdr = bswapLE16(*((LPWORD)pSrc));
// wHdr = bswapLE16(*((LPWORD)pSrc));
pSrc += 2;
bLeft = 9;
bTemp = bTemp2 = 0;
Expand Down Expand Up @@ -678,7 +675,7 @@ void ITUnpack16Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dw
{
signed short *pDst = (signed short *)pSample;
LPBYTE pSrc = lpMemFile;
DWORD wHdr = 0;
// DWORD wHdr = 0;
DWORD wCount = 0;
DWORD bitbuf = 0;
UINT bitnum = 0;
Expand All @@ -690,7 +687,7 @@ void ITUnpack16Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dw
if (!wCount)
{
wCount = 0x4000;
wHdr = bswapLE16(*((LPWORD)pSrc));
// wHdr = bswapLE16(*((LPWORD)pSrc));
pSrc += 2;
bLeft = 17;
wTemp = wTemp2 = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/libmodplug/load_okt.c
Expand Up @@ -40,7 +40,7 @@ BOOL CSoundFile_ReadOKT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
{
const OKTFILEHEADER *pfh = (OKTFILEHEADER *)lpStream;
DWORD dwMemPos = sizeof(OKTFILEHEADER);
UINT nsamples = 0, npatterns = 0, norders = 0;
UINT nsamples = 0, norders = 0;//, npatterns = 0

if ((!lpStream) || (dwMemLength < 1024)) return FALSE;
if ((pfh->okta != 0x41544B4F) || (pfh->song != 0x474E4F53)
Expand Down Expand Up @@ -84,7 +84,7 @@ BOOL CSoundFile_ReadOKT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
if (dwMemPos >= dwMemLength) return TRUE;
if (*((DWORD *)(lpStream + dwMemPos)) == 0x4E454C53)
{
npatterns = lpStream[dwMemPos+9];
// npatterns = lpStream[dwMemPos+9];
dwMemPos += bswapBE32(*((DWORD *)(lpStream + dwMemPos + 4))) + 8;
}
// PLEN
Expand Down
4 changes: 2 additions & 2 deletions src/libmodplug/load_psm.c
Expand Up @@ -97,7 +97,7 @@ BOOL CSoundFile_ReadPSM(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
{
PSMCHUNK pfh;
DWORD dwMemPos, dwSongPos;
DWORD smpnames[MAX_SAMPLES];
// DWORD smpnames[MAX_SAMPLES];
DWORD patptrs[MAX_PATTERNS];
BYTE samplemap[MAX_SAMPLES];
UINT nPatterns;
Expand Down Expand Up @@ -159,7 +159,7 @@ BOOL CSoundFile_ReadPSM(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
PSMSAMPLE psmp;
SDL_memcpy(&psmp, pdata, sizeof(PSMSAMPLE));
swap_PSMSAMPLE(&psmp);
smpnames[_this->m_nSamples] = psmp.smpid;
// smpnames[_this->m_nSamples] = psmp.smpid;
samplemap[_this->m_nSamples-1] = (BYTE)_this->m_nSamples;
// Init sample
pins->nGlobalVol = 0x40;
Expand Down
2 changes: 1 addition & 1 deletion src/stb_vorbis.h
Expand Up @@ -906,7 +906,7 @@ static int error(vorb *f, enum STBVorbisError e)
#define array_size_required(count,size) (count*(sizeof(void *)+(size)))

#define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size))
#define temp_free(f,p) 0
#define temp_free(f,p) (void)0
#define temp_alloc_save(f) ((f)->temp_offset)
#define temp_alloc_restore(f,p) ((f)->temp_offset = (p))

Expand Down

0 comments on commit 37223b0

Please sign in to comment.