Commit fccdd364 authored by Tommi Rantala's avatar Tommi Rantala

Call close() only if opened

Valgrind was complaining:
==9103== Warning: invalid file descriptor -1 in syscall close()
==9103== Warning: invalid file descriptor -1 in syscall close()
parent 5eaa5783
...@@ -104,7 +104,8 @@ AttachedProbe::AttachedProbe(Probe &probe, std::tuple<uint8_t *, uintptr_t> func ...@@ -104,7 +104,8 @@ AttachedProbe::AttachedProbe(Probe &probe, std::tuple<uint8_t *, uintptr_t> func
AttachedProbe::~AttachedProbe() AttachedProbe::~AttachedProbe()
{ {
close(progfd_); if (progfd_ >= 0)
close(progfd_);
int err = 0; int err = 0;
for (int perf_event_fd : perf_event_fds_) for (int perf_event_fd : perf_event_fds_)
......
...@@ -101,7 +101,8 @@ Map::Map(enum bpf_map_type map_type) ...@@ -101,7 +101,8 @@ Map::Map(enum bpf_map_type map_type)
Map::~Map() Map::~Map()
{ {
close(mapfd_); if (mapfd_ >= 0)
close(mapfd_);
} }
} // namespace bpftrace } // namespace bpftrace
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