update_engine: Fixes issues introduced in a previous AOSP CL.

Adds fcntl.h for using O_RDWR in file_descriptor_utils_unittest.cc.

Reorders includes in file_descriptor_utils_unittest.cc to the proper
code style.

Fixed some nits.

BUG=b:34284069
TEST=FEATURES="test" emerge-amd64-generic update_engine

Change-Id: Ib79b6cfd5ef0c0393373a017b6fb05b3c1b958ef
Reviewed-on: https://chromium-review.googlesource.com/641959
Commit-Ready: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
diff --git a/payload_consumer/fake_file_descriptor.cc b/payload_consumer/fake_file_descriptor.cc
index 09bd2c9..d54856b 100644
--- a/payload_consumer/fake_file_descriptor.cc
+++ b/payload_consumer/fake_file_descriptor.cc
@@ -23,7 +23,7 @@
   read_ops_.emplace_back(offset_, count);
 
   // Check for the EOF condition first to avoid reporting it as a failure.
-  if (offset_ >= static_cast<uint64_t>(size_) || !count)
+  if (offset_ >= static_cast<uint64_t>(size_) || count == 0)
     return 0;
   // Find the first offset greater or equal than the current position where a
   // failure will occur. This will mark the end of the read chunk.
diff --git a/payload_consumer/fake_file_descriptor.h b/payload_consumer/fake_file_descriptor.h
index ad49373..238dc2d 100644
--- a/payload_consumer/fake_file_descriptor.h
+++ b/payload_consumer/fake_file_descriptor.h
@@ -27,14 +27,14 @@
 namespace chromeos_update_engine {
 
 // A fake file descriptor with configurable errors. The file descriptor always
-// reads a fixed sequence of bytes, consisting on the concatenation of the
+// reads a fixed sequence of bytes, consisting of the concatenation of the
 // numbers 0, 1, 2... each one encoded in 4 bytes as the big-endian 16-bit
 // number encoded in hexadecimal. For example, the beginning of the stream in
 // ASCII is 0000000100020003... which corresponds to the numbers 0, 1, 2 and 3.
 class FakeFileDescriptor : public FileDescriptor {
  public:
   FakeFileDescriptor() = default;
-  ~FakeFileDescriptor() = default;
+  ~FakeFileDescriptor() override = default;
 
   // FileDescriptor override methods.
   bool Open(const char* path, int flags, mode_t mode) override {
@@ -86,7 +86,7 @@
   // Marks the range starting from |offset| bytes into the file and |length|
   // size as a failure range. Reads from this range will always fail.
   void AddFailureRange(uint64_t offset, uint64_t length) {
-    if (!length)
+    if (length == 0)
       return;
     failure_ranges_.emplace_back(offset, length);
   }
diff --git a/payload_consumer/file_descriptor_utils.h b/payload_consumer/file_descriptor_utils.h
index b73defb..6b2fd39 100644
--- a/payload_consumer/file_descriptor_utils.h
+++ b/payload_consumer/file_descriptor_utils.h
@@ -27,7 +27,7 @@
 namespace chromeos_update_engine {
 namespace fd_utils {
 
-// Copy a blocks from the |source| file to the |target| file and hash the
+// Copy blocks from the |source| file to the |target| file and hashes the
 // contents. The blocks to copy from the |source| to the |target| files are
 // specified by the |src_extents| and |tgt_extents| list of Extents, which
 // must have the same length in number of blocks. Stores the hash of the
diff --git a/payload_consumer/file_descriptor_utils_unittest.cc b/payload_consumer/file_descriptor_utils_unittest.cc
index 9910239..42bdf17 100644
--- a/payload_consumer/file_descriptor_utils_unittest.cc
+++ b/payload_consumer/file_descriptor_utils_unittest.cc
@@ -16,13 +16,14 @@
 
 #include "update_engine/payload_consumer/file_descriptor_utils.h"
 
+#include <fcntl.h>
+
 #include <string>
 #include <utility>
 #include <vector>
 
-#include <gtest/gtest.h>
-
 #include <brillo/data_encoding.h>
+#include <gtest/gtest.h>
 
 #include "update_engine/common/hash_calculator.h"
 #include "update_engine/common/test_utils.h"