diff options
author | Pierre-André Jacquod <pjacquod@alumni.ethz.ch> | 2011-10-03 12:59:01 +0200 |
---|---|---|
committer | Pierre-André Jacquod <pjacquod@alumni.ethz.ch> | 2011-10-07 15:57:53 +0200 |
commit | 3f7fd933b3feab7924998e11b4a49c1d27c7fa2c (patch) | |
tree | 7797d730b1ca54a5532ea1bd202504a40e2340bd /dmake/state.c | |
parent | 7bd7d37f58ee7dbc893201d57940cf851fa9dce1 (diff) |
cppcheck reduce scope of var in dmake/state.c
Diffstat (limited to 'dmake/state.c')
-rw-r--r-- | dmake/state.c | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/dmake/state.c b/dmake/state.c index 5179ead4fd14..569ceee0995f 100644 --- a/dmake/state.c +++ b/dmake/state.c @@ -52,41 +52,39 @@ Read_state() { char *buf; char sizeb[20]; - int size; FILE *fp; KSTATEPTR sp; - if( (fp = Search_file(".KEEP_STATE", &_st_file)) != NIL(FILE) ) { - if( _my_fgets( sizeb, 20, fp ) ) { - size = atol(sizeb); - buf = MALLOC(size+2, char); - - while( _my_fgets(buf, size, fp) ) { - TALLOC(sp, 1, KSTATE); - sp->st_name = DmStrDup(buf); - (void) Hash(buf, &sp->st_nkey); - - if( _my_fgets(buf, size, fp) ) sp->st_count = atoi(buf); - if( _my_fgets(buf, size, fp) ) sp->st_dkey = (uint32) atol(buf); - - if( _my_fgets(buf, size, fp) ) - sp->st_key = (uint32) atol(buf); - else { - FREE(sp); - break; + if( (fp = Search_file(".KEEP_STATE", &_st_file)) != NIL(FILE) ) + { + if( _my_fgets( sizeb, 20, fp ) ) + { + int size = atol(sizeb); + buf = MALLOC(size+2, char); + + while( _my_fgets(buf, size, fp) ) + { + TALLOC(sp, 1, KSTATE); + sp->st_name = DmStrDup(buf); + (void) Hash(buf, &sp->st_nkey); + if( _my_fgets(buf, size, fp) ) + sp->st_count = atoi(buf); + if( _my_fgets(buf, size, fp) ) + sp->st_dkey = (uint32) atol(buf); + if( _my_fgets(buf, size, fp) ) + sp->st_key = (uint32) atol(buf); + else { + FREE(sp); + break; + } + if( _st_head == NIL(KSTATE) ) + _st_head = sp; + else + _st_tail->st_next = sp; + _st_tail = sp; + } + FREE(buf); } - - if( _st_head == NIL(KSTATE) ) - _st_head = sp; - else - _st_tail->st_next = sp; - - _st_tail = sp; - } - - FREE(buf); - } - Closefile(); } } |