# HG changeset patch # User Matti Hamalainen # Date 1503182865 -10800 # Node ID 4670907412e70b472727976bfc07e88e88ca47ee # Parent eb3f883f4acb5e058e6d6d0ce9152591d0eb3ca4 Cleanups. diff -r eb3f883f4acb -r 4670907412e7 minijss/jloadjss.c --- 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;