Minor change

This commit is contained in:
Robin Nicholson 2018-03-15 19:53:38 +01:00
parent 408a1b6e5e
commit 84659a2a43
1 changed files with 4 additions and 3 deletions

View File

@ -10,6 +10,7 @@
#include "elfspy/Fail.h" #include "elfspy/Fail.h"
namespace spy namespace spy
{ {
@ -19,11 +20,11 @@ MFile::MFile(const char* file_name)
if (fd_ < 0) { if (fd_ < 0) {
Fail() << "Cannot open " << file_name; Fail() << "Cannot open " << file_name;
} }
struct stat file; struct stat file_info;
if (fstat(fd_, &file) < 0) { if (fstat(fd_, &file_info) < 0) {
Fail() << "Cannot fstat " << file_name; Fail() << "Cannot fstat " << file_name;
} }
size_ = file.st_size; size_ = file_info.st_size;
address_ = reinterpret_cast<unsigned char*>( address_ = reinterpret_cast<unsigned char*>(
mmap(nullptr, size_, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd_, 0)); mmap(nullptr, size_, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd_, 0));
if (address_ == MAP_FAILED) { if (address_ == MAP_FAILED) {