Mercurial > hg > dmlib
changeset 1314:4670907412e7
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 20 Aug 2017 01:47:45 +0300 |
parents | eb3f883f4acb |
children | 7687412f9aef |
files | minijss/jloadjss.c |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/minijss/jloadjss.c Sun Aug 20 01:38:36 2017 +0300 +++ b/minijss/jloadjss.c Sun Aug 20 01:47:45 2017 +0300 @@ -264,7 +264,6 @@ JSSEnvelope *env, const char *name, const int ninst) { JSSMODEnvelope jssEnv; - int i; // Read envelope data if (!dmf_read_byte(inFile, &jssEnv.flags) || @@ -272,18 +271,22 @@ !dmf_read_byte(inFile, &jssEnv.sustain) || !dmf_read_byte(inFile, &jssEnv.loopS) || !dmf_read_byte(inFile, &jssEnv.loopE)) + { JSSERROR(DMERR_FREAD, DMERR_FREAD, "Failed to read %s-envelope data for instrument #%d.\n", name, ninst); + } // Do some sanity checking if (jssEnv.npoints > jsetMaxEnvPoints || jssEnv.loopS < jssEnv.loopE || jssEnv.loopS > jssEnv.npoints || jssEnv.loopE > jssEnv.npoints) + { JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, "Invalid values in %s-envelope for instrument #%d.\n", name, ninst); + } // Copy data env->flags = jssEnv.flags; @@ -292,14 +295,16 @@ env->loopS = jssEnv.loopS; env->loopE = jssEnv.loopE; - for (i = 0; i < jssEnv.npoints; i++) + for (int i = 0; i < jssEnv.npoints; i++) { Uint16 frame, value; if (!dmf_read_le16(inFile, &frame) || !dmf_read_le16(inFile, &value)) + { JSSERROR(DMERR_FREAD, DMERR_FREAD, "Failed to read %s-envelope values (%d) for instrument #%d.\n", name, i, ninst); + } env->points[i].frame = frame; env->points[i].value = value;