Fix signed integer overflow in StaticTracepointTest.cpp
[folly.git] / folly / FileUtil.cpp
index 70a8e095f7478e5d5635f80fc97afffd005e2fb6..ce61ad963193d32a35a33dad592d436354454df8 100644 (file)
@@ -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.
 #include <folly/detail/FileUtilDetail.h>
 #include <folly/portability/Fcntl.h>
 #include <folly/portability/Sockets.h>
+#include <folly/portability/Stdlib.h>
 #include <folly/portability/SysFile.h>
+#include <folly/portability/SysStat.h>
 
 namespace folly {
 
 using namespace fileutil_detail;
 
 int openNoInt(const char* name, int flags, mode_t mode) {
-  return wrapNoInt(open, name, flags, mode);
+  return int(wrapNoInt(open, name, flags, mode));
 }
 
 int closeNoInt(int fd) {
@@ -50,41 +52,41 @@ int closeNoInt(int fd) {
 }
 
 int fsyncNoInt(int fd) {
-  return wrapNoInt(fsync, fd);
+  return int(wrapNoInt(fsync, fd));
 }
 
 int dupNoInt(int fd) {
-  return wrapNoInt(dup, fd);
+  return int(wrapNoInt(dup, fd));
 }
 
 int dup2NoInt(int oldfd, int newfd) {
-  return wrapNoInt(dup2, oldfd, newfd);
+  return int(wrapNoInt(dup2, oldfd, newfd));
 }
 
 int fdatasyncNoInt(int fd) {
 #if defined(__APPLE__)
-  return wrapNoInt(fcntl, fd, F_FULLFSYNC);
+  return int(wrapNoInt(fcntl, fd, F_FULLFSYNC));
 #elif defined(__FreeBSD__) || defined(_MSC_VER)
-  return wrapNoInt(fsync, fd);
+  return int(wrapNoInt(fsync, fd));
 #else
-  return wrapNoInt(fdatasync, fd);
+  return int(wrapNoInt(fdatasync, fd));
 #endif
 }
 
 int ftruncateNoInt(int fd, off_t len) {
-  return wrapNoInt(ftruncate, fd, len);
+  return int(wrapNoInt(ftruncate, fd, len));
 }
 
 int truncateNoInt(const char* path, off_t len) {
-  return wrapNoInt(truncate, path, len);
+  return int(wrapNoInt(truncate, path, len));
 }
 
 int flockNoInt(int fd, int operation) {
-  return wrapNoInt(flock, fd, operation);
+  return int(wrapNoInt(flock, fd, operation));
 }
 
 int shutdownNoInt(int fd, int how) {
-  return wrapNoInt(portability::sockets::shutdown, fd, how);
+  return int(wrapNoInt(portability::sockets::shutdown, fd, how));
 }
 
 ssize_t readNoInt(int fd, void* buf, size_t count) {
@@ -233,4 +235,4 @@ void writeFileAtomic(
   writeFileAtomic(filename, ByteRange(data), permissions);
 }
 
-}  // namespaces
+} // namespace folly