forked from len0rd/rockbox
imxtools: remove most calls to bug/bugp from core library.
It should not exit() anymore on error except on malloc failure. Resource leaks on errors (especially I/O) are quite likely though. Change-Id: I6fcf72fb08fc683468b390d0b8745d31ca982b48
This commit is contained in:
parent
2d7a4e9dfa
commit
c483905b92
6 changed files with 50 additions and 14 deletions
|
@ -460,13 +460,21 @@ struct cmd_file_t *db_parse_file(const char *file)
|
|||
size_t size;
|
||||
FILE *f = fopen(file, "r");
|
||||
if(f == NULL)
|
||||
bugp("Cannot open file '%s'", file);
|
||||
{
|
||||
if(g_debug)
|
||||
perror("Cannot open db file");
|
||||
return NULL;
|
||||
}
|
||||
fseek(f, 0, SEEK_END);
|
||||
size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
char *buf = xmalloc(size);
|
||||
if(fread(buf, size, 1, f) != 1)
|
||||
bugp("Cannot read file '%s'", file);
|
||||
{
|
||||
if(g_debug)
|
||||
perror("Cannot read db file");
|
||||
return NULL;
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
if(g_debug)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue