From 1041ecf8d0da9cdde6c240016d792583bdf3d33c Mon Sep 17 00:00:00 2001 From: rlar Date: Thu, 30 Jun 2011 16:33:10 +0000 Subject: [PATCH] suprmitf.c, uninitialized variable warning --- ChangeLog | 4 ++++ src/ciderlib/support/suprmitf.c | 28 ++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 70c40ad90..673ebdb19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-06-30 Robert Larice + * src/ciderlib/support/suprmitf.c : + suprmitf.c, uninitialized variable warning + 2011-06-30 Robert Larice * src/frontend/com_measure2.c : com_measure2.c, uninitialized variable warning diff --git a/src/ciderlib/support/suprmitf.c b/src/ciderlib/support/suprmitf.c index 238d3fecf..7adc75ee8 100644 --- a/src/ciderlib/support/suprmitf.c +++ b/src/ciderlib/support/suprmitf.c @@ -202,11 +202,17 @@ SUPbinRead(char *inFile, float *x, float *conc, int *impId, int *numNod) fclose( fpSuprem ); /* shift silicon layer to beginning of array */ - for ( j=0; j < numLay; j++ ) { - if (matTyp[ j ] == 1) { - siIndex = j; - } + for ( j=numLay; --j >= 0; ) + if (matTyp[ j ] == 1) + break; + + if(j < 0) { + fprintf(stderr, "internal error in %s, bye !\n", __FUNCTION__); + exit(1); } + + siIndex = j; + offset = topNod[ siIndex ] - 1; numGrid -= offset; xStart = x[1 + offset]; @@ -332,11 +338,17 @@ SUPascRead(char *inFile, float *x, float *conc, int *impId, int *numNod) /* shift silicon layer to beginning of array */ - for ( j=0; j < numLay; j++ ) { - if (matTyp[ j ] == 1) { - siIndex = j; - } + for ( j=numLay; --j >= 0; ) + if (matTyp[ j ] == 1) + break; + + if(j < 0) { + fprintf(stderr, "internal error in %s, bye !\n", __FUNCTION__); + exit(1); } + + siIndex = j; + offset = topNod[ siIndex ] - 1; numGrid -= offset; xStart = x[1 + offset];