From: Christopher Dykes Date: Thu, 25 Aug 2016 21:52:59 +0000 (-0700) Subject: lseek returns the new offset, not 0 X-Git-Tag: v2016.08.29.00~8 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ff5c9335246b6b02bbe9435744722415423f348d;p=folly.git lseek returns the new offset, not 0 Summary: With how this was written it would fail if the call to `lseek` failed, or if it succeeded, unless it was setting the length to 0, in which case it would succeed. This makes it work right. Reviewed By: yfeldblum Differential Revision: D3773311 fbshipit-source-id: 3dc94502d0c4259f6f2766b4c0903c081d7c36ab --- diff --git a/folly/portability/Unistd.cpp b/folly/portability/Unistd.cpp index 27fc7c77..bf598d23 100755 --- a/folly/portability/Unistd.cpp +++ b/folly/portability/Unistd.cpp @@ -92,7 +92,7 @@ int fsync(int fd) { } int ftruncate(int fd, off_t len) { - if (_lseek(fd, len, SEEK_SET)) { + if (_lseek(fd, len, SEEK_SET) == -1) { return -1; }