[gn][fs-host] Fix signedness warnings in common.cpp

Ensure that ssize_t/off_t are >= 0 before comparing to size_t in a couple
locations.

ZX-3415 #comment [gn][fs-host] Fix signedness warnings in common.cpp

Test: CQ
Change-Id: I2d4f6e168c1d6f253397b06e51affa5c5f224cee
diff --git a/zircon/system/ulib/fs-host/common.cpp b/zircon/system/ulib/fs-host/common.cpp
index a948199..2c7be49 100644
--- a/zircon/system/ulib/fs-host/common.cpp
+++ b/zircon/system/ulib/fs-host/common.cpp
@@ -245,9 +245,17 @@
             break;
         case 'o':
             offset_ = atoll(optarg);
+            if (offset_ < 0) {
+                fprintf(stderr, "error: offset < 0\n");
+                return ZX_ERR_INVALID_ARGS;
+            }
             break;
         case 'l':
             length_ = atoll(optarg);
+            if (length_ < 0) {
+                fprintf(stderr, "error: length < 0\n");
+                return ZX_ERR_INVALID_ARGS;
+            }
             break;
         case 'c':
             compress_ = true;
@@ -433,7 +441,8 @@
 
     // this code makes assumptions about the size of atomic writes on target
     // platforms which currently hold true, but are not part of e.g. POSIX.
-    if (write(depfile_.get(), buf, len) != len) {
+    ssize_t result = write(depfile_.get(), buf, len);
+    if (result < 0 || static_cast<size_t>(result) != len) {
         fprintf(stderr, "error: depfile append error\n");
         return ZX_ERR_IO;
     }
@@ -496,7 +505,7 @@
             return ZX_ERR_INVALID_ARGS;
         }
 
-        if (length_ && offset_ + length_ > size) {
+        if (length_ && static_cast<size_t>(offset_ + length_) > size) {
             fprintf(stderr, "Must specify size > offset + length\n");
             return ZX_ERR_INVALID_ARGS;
         }