Kaydet (Commit) 3f7fd933 authored tarafından Pierre-André Jacquod's avatar Pierre-André Jacquod

cppcheck reduce scope of var in dmake/state.c

üst 7bd7d37f
...@@ -52,41 +52,39 @@ Read_state() ...@@ -52,41 +52,39 @@ Read_state()
{ {
char *buf; char *buf;
char sizeb[20]; char sizeb[20];
int size;
FILE *fp; FILE *fp;
KSTATEPTR sp; KSTATEPTR sp;
if( (fp = Search_file(".KEEP_STATE", &_st_file)) != NIL(FILE) ) { if( (fp = Search_file(".KEEP_STATE", &_st_file)) != NIL(FILE) )
if( _my_fgets( sizeb, 20, fp ) ) { {
size = atol(sizeb); if( _my_fgets( sizeb, 20, fp ) )
buf = MALLOC(size+2, char); {
int size = atol(sizeb);
while( _my_fgets(buf, size, fp) ) { buf = MALLOC(size+2, char);
TALLOC(sp, 1, KSTATE);
sp->st_name = DmStrDup(buf); while( _my_fgets(buf, size, fp) )
(void) Hash(buf, &sp->st_nkey); {
TALLOC(sp, 1, KSTATE);
if( _my_fgets(buf, size, fp) ) sp->st_count = atoi(buf); sp->st_name = DmStrDup(buf);
if( _my_fgets(buf, size, fp) ) sp->st_dkey = (uint32) atol(buf); (void) Hash(buf, &sp->st_nkey);
if( _my_fgets(buf, size, fp) )
if( _my_fgets(buf, size, fp) ) sp->st_count = atoi(buf);
sp->st_key = (uint32) atol(buf); if( _my_fgets(buf, size, fp) )
else { sp->st_dkey = (uint32) atol(buf);
FREE(sp); if( _my_fgets(buf, size, fp) )
break; 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(); Closefile();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment