Fix copyright lines
[folly.git] / folly / detail / FileUtilDetail.h
index bcebc5fc08f82b111c5a1be84c0e1295da0b1e53..c834acf54046835756c1300d4f90e29e567f5c3b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2013-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
 namespace folly { namespace fileutil_detail {
 
 // Wrap call to f(args) in loop to retry on EINTR
-template<class F, class... Args>
+template <class F, class... Args>
 ssize_t wrapNoInt(F f, Args... args) {
   ssize_t r;
   do {
@@ -38,7 +38,7 @@ ssize_t wrapNoInt(F f, Args... args) {
 }
 
 inline void incr(ssize_t /* n */) {}
-inline void incr(ssize_t n, off_t& offset) { offset += n; }
+inline void incr(ssize_t n, off_t& offset) { offset += off_t(n); }
 
 // Wrap call to read/pread/write/pwrite(fd, buf, count, offset?) to retry on
 // incomplete reads / writes.  The variadic argument magic is there to support
@@ -73,10 +73,10 @@ ssize_t wrapFull(F f, int fd, void* buf, size_t count, Offset... offset) {
 template <class F, class... Offset>
 ssize_t wrapvFull(F f, int fd, iovec* iov, int count, Offset... offset) {
   ssize_t totalBytes = 0;
-  size_t r;
+  ssize_t r;
   do {
     r = f(fd, iov, std::min<int>(count, kIovMax), offset...);
-    if (r == (size_t)-1) {
+    if (r == -1) {
       if (errno == EINTR) {
         continue;
       }
@@ -90,8 +90,8 @@ ssize_t wrapvFull(F f, int fd, iovec* iov, int count, Offset... offset) {
     totalBytes += r;
     incr(r, offset...);
     while (r != 0 && count != 0) {
-      if (r >= iov->iov_len) {
-        r -= iov->iov_len;
+      if (r >= ssize_t(iov->iov_len)) {
+        r -= ssize_t(iov->iov_len);
         ++iov;
         --count;
       } else {
@@ -105,4 +105,5 @@ ssize_t wrapvFull(F f, int fd, iovec* iov, int count, Offset... offset) {
   return totalBytes;
 }
 
-}}  // namespaces
+} // namespace fileutil_detail
+} // namespace folly