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 ) )
{
int size = atol(sizeb);
buf = MALLOC(size+2, char); buf = MALLOC(size+2, char);
while( _my_fgets(buf, size, fp) ) { while( _my_fgets(buf, size, fp) )
{
TALLOC(sp, 1, KSTATE); TALLOC(sp, 1, KSTATE);
sp->st_name = DmStrDup(buf); sp->st_name = DmStrDup(buf);
(void) Hash(buf, &sp->st_nkey); (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_count = atoi(buf);
if( _my_fgets(buf, size, fp) ) sp->st_dkey = (uint32) atol(buf); if( _my_fgets(buf, size, fp) )
sp->st_dkey = (uint32) atol(buf);
if( _my_fgets(buf, size, fp) ) if( _my_fgets(buf, size, fp) )
sp->st_key = (uint32) atol(buf); sp->st_key = (uint32) atol(buf);
else { else {
FREE(sp); FREE(sp);
break; break;
} }
if( _st_head == NIL(KSTATE) ) if( _st_head == NIL(KSTATE) )
_st_head = sp; _st_head = sp;
else else
_st_tail->st_next = sp; _st_tail->st_next = sp;
_st_tail = sp; _st_tail = sp;
} }
FREE(buf); 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