mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 11:38:20 +00:00
Improve return value checking and error handling.
This commit is contained in:
parent
4b24cebad9
commit
daf5d0d098
14 changed files with 101 additions and 33 deletions
|
@ -935,7 +935,7 @@ static const char* check_for_dir(const char* filename, bool load_pkgs)
|
|||
return copy_string(filename);
|
||||
}
|
||||
|
||||
FILE* open_file(const char* filename, const char** full_filename, bool load_pkgs)
|
||||
static FILE* open_file(const char* filename, const char** full_filename, bool load_pkgs)
|
||||
{
|
||||
filename = check_for_dir(filename, load_pkgs);
|
||||
|
||||
|
@ -944,6 +944,13 @@ FILE* open_file(const char* filename, const char** full_filename, bool load_pkgs
|
|||
|
||||
FILE* f = fopen(filename, "r");
|
||||
|
||||
if ( ! f )
|
||||
{
|
||||
char buf[256];
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
reporter->Error("Failed to open file %s: %s", filename, buf);
|
||||
}
|
||||
|
||||
delete [] filename;
|
||||
|
||||
return f;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue