Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a998b157 authored by Greg Kaiser's avatar Greg Kaiser
Browse files

Fix file open check

fd.ok() returns a bool.  The NOT of that method will auto-cast to
a 0 or 1 as an int, and thus will never equal -1.  So our previous
check was always false.  We remove the int comparison to fix this.

Test: TreeHugger
Change-Id: I20ad5eae79622f680c5516df422a7fef7ff7966b
parent 1b2e16d6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ bool TunForwarder::addForwardingRule(const std::array<std::string, 2>& from,

unique_fd TunForwarder::createTun(const std::string& ifname) {
    unique_fd fd(open("/dev/tun", O_RDWR | O_NONBLOCK | O_CLOEXEC));
    if (!fd.ok() == -1) {
    if (!fd.ok()) {
        return {};
    }