# HG changeset patch # User Matti Hamalainen # Date 1509380111 -7200 # Node ID 6aa0897265e85a1524deef0f122a3177ddb26723 # Parent b47109fce3758bf28c0f9842cdf4504740eb38b8 Modernization cleanups. diff -r b47109fce375 -r 6aa0897265e8 minijss/jssmix.c --- a/minijss/jssmix.c Mon Oct 30 18:12:38 2017 +0200 +++ b/minijss/jssmix.c Mon Oct 30 18:15:11 2017 +0200 @@ -68,9 +68,7 @@ static int jvmFindMixRoutine(int outFormat, int outChannels, int mixerID) { - int i; - - for (i = 0; i < jvmNMixRoutines; i++) + for (int i = 0; i < jvmNMixRoutines; i++) { if (jvmMixRoutines[i].outFormat == outFormat && jvmMixRoutines[i].outChannels == outChannels && @@ -373,7 +371,7 @@ void jvmRenderAudio(JSSMixer *mixer, void *mixBuffer, const int mixLength) { - int i, blockLength, mixLeft; + int blockLength, mixLeft; JMIXER_ADDBUF_TYPE *ab; JSS_LOCK(mixer); @@ -406,7 +404,7 @@ } // Do mixing - for (i = 0; i < jsetNChannels; i++) + for (int i = 0; i < jsetNChannels; i++) { JSSChannel *chn = &(mixer->channels[i]); if (chn->chPlaying && !chn->chMute) diff -r b47109fce375 -r 6aa0897265e8 minijss/jssmod.c --- a/minijss/jssmod.c Mon Oct 30 18:12:38 2017 +0200 +++ b/minijss/jssmod.c Mon Oct 30 18:15:11 2017 +0200 @@ -232,12 +232,11 @@ */ int jssConvertModuleForPlaying(JSSModule *module) { - int i; if (module == NULL) return DMERR_NULLPTR; // Convert instruments - for (i = 0; i < module->ninstruments; i++) + for (int i = 0; i < module->ninstruments; i++) { JSSInstrument *inst = module->instruments[i]; if (inst != NULL && inst->data != NULL) @@ -267,7 +266,6 @@ */ JSSModule *jssAllocateModule(void) { - int i; JSSModule *module; // Allocate module structure @@ -276,10 +274,10 @@ return NULL; // Initialize structure - for (i = 0; i < jsetNChannels; i++) + for (int i = 0; i < jsetNChannels; i++) module->defPanning[i] = jchPanMiddle; - for (i = 0; i < jsetMaxOrders; i++) + for (int i = 0; i < jsetMaxOrders; i++) module->orderList[i] = jsetOrderEnd; // Allocate mutex @@ -296,8 +294,6 @@ */ int jssFreeModule(JSSModule * module) { - int i; - if (module == NULL) return DMERR_NULLPTR; @@ -308,18 +304,18 @@ #endif // Free patterns - for (i = 0; i < module->npatterns; i++) + for (int i = 0; i < module->npatterns; i++) jssFreePattern(module->patterns[i]); // Free the "empty" pattern jssFreePattern(module->patterns[jsetMaxPatterns]); // Free instruments - for (i = 0; i < module->ninstruments; i++) + for (int i = 0; i < module->ninstruments; i++) jssFreeInstrument(module->instruments[i]); // Free extended instruments - for (i = 0; i < module->nextInstruments; i++) + for (int i = 0; i < module->nextInstruments; i++) jssFreeExtInstrument(module->extInstruments[i]); // Free mutex @@ -339,7 +335,6 @@ */ JSSPattern *jssAllocatePattern(const int nrows, const int nchannels) { - int row, chn; JSSPattern *pattern; JSSNote *pnote; @@ -365,15 +360,13 @@ pattern->nchannels = nchannels; pnote = pattern->data; - for (row = 0; row < nrows; row++) + for (int row = 0; row < nrows; row++) + for (int chn = 0; chn < nchannels; chn++) { - for (chn = 0; chn < nchannels; chn++) - { - pnote->note = pnote->instrument = pnote->volume = - pnote->effect = pnote->param = jsetNotSet; + pnote->note = pnote->instrument = pnote->volume = + pnote->effect = pnote->param = jsetNotSet; - pnote++; - } + pnote++; } return pattern; @@ -421,7 +414,6 @@ */ JSSExtInstrument *jssAllocateExtInstrument(void) { - int i; JSSExtInstrument *inst; // Allocate a instrument structure @@ -429,7 +421,7 @@ return NULL; // Initialize the requisite fields - for (i = 0; i < jsetNNotes; i++) + for (int i = 0; i < jsetNNotes; i++) inst->sNumForNotes[i] = jsetNotSet; return inst; diff -r b47109fce375 -r 6aa0897265e8 minijss/jssplr.c --- a/minijss/jssplr.c Mon Oct 30 18:12:38 2017 +0200 +++ b/minijss/jssplr.c Mon Oct 30 18:15:11 2017 +0200 @@ -299,7 +299,6 @@ void jmpClearPlayer(JSSPlayer * mp) { - int i; assert(mp != NULL); JSS_LOCK(mp); @@ -312,7 +311,7 @@ mp->lastPatLoopRow = 0; // Initialize channel data - for (i = 0; i < jsetNChannels; i++) + for (int i = 0; i < jsetNChannels; i++) jmpClearChannel(&mp->channels[i]); JSS_UNLOCK(mp); @@ -431,17 +430,16 @@ static void jmpClearChannels(JSSPlayer * mp) { - int i; assert(mp != NULL); JSS_LOCK(mp); assert(mp->device != NULL); assert(mp->module != NULL); - for (i = 0; i < mp->module->nchannels; i++) + for (int i = 0; i < mp->module->nchannels; i++) jvmStop(mp->device, i); // Initialize channel data - for (i = 0; i < jsetNChannels; i++) + for (int i = 0; i < jsetNChannels; i++) jmpClearChannel(&mp->channels[i]); JSS_UNLOCK(mp); @@ -1391,7 +1389,6 @@ void jmpExec(void *pDEV, void *pMP) { JSSPlayer *mp; - int channel; // Check some things via assert() mp = (JSSPlayer *) pMP; @@ -1408,7 +1405,7 @@ mp->jumpFlag = FALSE; mp->breakFlag = FALSE; - for (channel = 0; channel < jsetNChannels; channel++) + for (int channel = 0; channel < jsetNChannels; channel++) mp->channels[channel].newDataFlags = 0; //fprintf(stderr, "1: tick=%d, order=%d, iPattern=%d, row=%d\n", mp->tick, mp->order, mp->npattern, mp->row); @@ -1483,7 +1480,7 @@ goto out; // TICK #0: Process new row - for (channel = 0; channel < mp->module->nchannels; channel++) + for (int channel = 0; channel < mp->module->nchannels; channel++) jmpProcessNewRow(mp, channel); } // patternDelay } // tick @@ -1494,7 +1491,7 @@ (JMPGETMODFLAGS(mp, jmdfFT2Replay) && mp->patternDelay <= 0)) { // TICK n: Process the effects - for (channel = 0; channel < mp->module->nchannels; channel++) + for (int channel = 0; channel < mp->module->nchannels; channel++) jmpProcessEffects(mp, channel); } } @@ -1504,7 +1501,7 @@ goto out; // Update player data to audio device/mixer - for (channel = 0; channel < mp->module->nchannels; channel++) + for (int channel = 0; channel < mp->module->nchannels; channel++) { JSSPlayerChannel *chn = &mp->channels[channel];