It turns out that some of the BPF helper functions return
a negative `errno` value in case of failure, and since we
wrap the return value into a `FDWrapper` right away this
led to a warning from Valgrind about trying to close an
invalid file descriptor.
(cherry picked from commit
ef1e068d55f2247ff416204cebbbb96063a175c2)
FDWrapper& operator=(FDWrapper&& rhs) noexcept
{
- if (d_fd != -1) {
+ if (d_fd >= 0) {
close(d_fd);
}
d_fd = rhs.d_fd;
void reset()
{
- if (d_fd != -1) {
+ if (d_fd >= 0) {
::close(d_fd);
d_fd = -1;
}