X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FFile.cpp;h=9fb755a8468e37a2c212f18f8369ef3faa211803;hp=091e0103e901067887615fceea3804f7843fb82a;hb=eb7bc45f22e034751a76bf02445c669471e60780;hpb=64ed63b21b65298764750e73d6493da47061dc9d diff --git a/folly/File.cpp b/folly/File.cpp index 091e0103..9fb755a8 100644 --- a/folly/File.cpp +++ b/folly/File.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,14 @@ #include -#include -#include #include #include #include #include +#include #include +#include #include @@ -31,14 +31,9 @@ namespace folly { -File::File() - : fd_(-1) - , ownsFd_(false) -{} +File::File() noexcept : fd_(-1), ownsFd_(false) {} -File::File(int fd, bool ownsFd) - : fd_(fd) - , ownsFd_(ownsFd) { +File::File(int fd, bool ownsFd) noexcept : fd_(fd), ownsFd_(ownsFd) { CHECK_GE(fd, -1) << "fd must be -1 or non-negative"; CHECK(fd != -1 || !ownsFd) << "cannot own -1"; } @@ -143,7 +138,9 @@ void File::doLock(int op) { bool File::doTryLock(int op) { int r = flockNoInt(fd_, op | LOCK_NB); // flock returns EWOULDBLOCK if already locked - if (r == -1 && errno == EWOULDBLOCK) return false; + if (r == -1 && errno == EWOULDBLOCK) { + return false; + } checkUnixError(r, "flock() failed (try_lock)"); return true; } @@ -153,4 +150,4 @@ void File::unlock() { } void File::unlock_shared() { unlock(); } -} // namespace folly +} // namespace folly