Improve return value checking and error handling.

This commit is contained in:
Jon Siwek 2013-09-24 17:38:22 -05:00
parent 4b24cebad9
commit daf5d0d098
14 changed files with 101 additions and 33 deletions

View file

@ -6,6 +6,7 @@
#include <map>
#include <stdio.h>
#include <errno.h>
#include <string>
#include <vector>
@ -80,7 +81,12 @@ bool LoadPolicyFileText(const char* policy_filename)
policy_files.insert(PolicyFileMap::value_type(policy_filename, pf));
struct stat st;
fstat(fileno(f), &st);
if ( fstat(fileno(f), &st) != 0 )
{
char buf[256];
strerror_r(errno, buf, sizeof(buf));
reporter->InternalError("fstat failed on %s: %s", policy_filename, buf);
}
pf->lmtime = st.st_mtime;
off_t size = st.st_size;