Fix a compiler warning.

The compiler barks about fd being used without potentially being
initialized. We fix this and also make the code more future proof by
ensuring that the file is closed iff it was previously opened,
regardless of the path conditions that led to it being opened.

BUG=chromium:386393
TEST=Package builds.

Change-Id: I5e2a2a5653b5ebe1c1c73e7193d7b226d8b5bd16
Reviewed-on: https://chromium-review.googlesource.com/204628
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/gobi_handle_test.cc b/gobi_handle_test.cc
index b355204..e029312 100644
--- a/gobi_handle_test.cc
+++ b/gobi_handle_test.cc
@@ -189,7 +189,7 @@
   log("USB path: %s", usb_path);
   log("device path: %s", qmi_device_path);
 
-  int fd;
+  int fd = -1;
   ULONG rc;
 
   if (use_qcwwan) {
@@ -225,12 +225,15 @@
     if (rc != 0) {
       log("Failed on disconnect: %d", rc);
     }
-  } else {
+  }
+
+  if (fd >= 0) {
     rc = close(fd);
     if (rc != 0) {
       log("Failed on close: %d", rc);
     }
   }
+
   log("exiting");
   return 0;
 }