Ijar: remove spurious error message

Commit 645dbc4 moved the file stating logic to
platform_utils.cc into the `stat_file` method,
then commit 8d6da00 added error reporting to that
method so callers wouldn't need to report errors
on their own. Problem is, one of the callers was
using stat_file for simple file existence checking
so reporting an error there was spurious.

Fixes https://github.com/bazelbuild/bazel/issues/2201

--
Change-Id: I40d1ee2bad8f3d03627c0b5c0bfd593bb5289d23
Reviewed-on: https://cr.bazel.build/7810
PiperOrigin-RevId: 141739581
MOS_MIGRATED_REVID=141739581
diff --git a/third_party/ijar/platform_utils.cc b/third_party/ijar/platform_utils.cc
index 9c00ccc..5eced72 100644
--- a/third_party/ijar/platform_utils.cc
+++ b/third_party/ijar/platform_utils.cc
@@ -40,7 +40,6 @@
 #else   // not COMPILER_MSVC
   struct stat statst;
   if (stat(path, &statst) < 0) {
-    fprintf(stderr, "Cannot stat file %s: %s\n", path, strerror(errno));
     return false;
   }
   result->total_size = statst.st_size;
diff --git a/third_party/ijar/platform_utils.h b/third_party/ijar/platform_utils.h
index 5d0eb6b..fc522c3 100644
--- a/third_party/ijar/platform_utils.h
+++ b/third_party/ijar/platform_utils.h
@@ -40,8 +40,10 @@
 }
 
 // Writes stat data into `result` about the file under `path`.
-// Returns true upon success: file is found and can be stat'ed.
-// Returns false upon failure and reports the error to stderr.
+// Returns true if file is found and can be stat'ed.
+// Returns false if the file is not found or cannot be stat'ed.
+// Doesn't report any errors because it can also be used to simply check if a
+// file exists.
 bool stat_file(const char* path, Stat* result);
 
 // Writes `size` bytes from `data` into file under `path`.
diff --git a/third_party/ijar/zip_main.cc b/third_party/ijar/zip_main.cc
index 13bcc69..51aea541 100644
--- a/third_party/ijar/zip_main.cc
+++ b/third_party/ijar/zip_main.cc
@@ -166,6 +166,7 @@
   Stat file_stat = {0, 0666, false};
   if (file != NULL) {
     if (!stat_file(file, &file_stat)) {
+      fprintf(stderr, "Cannot stat file %s: %s\n", file, strerror(errno));
       return -1;
     }
   }
@@ -218,6 +219,7 @@
 char **read_filelist(char *filename) {
   Stat file_stat;
   if (!stat_file(filename, &file_stat)) {
+    fprintf(stderr, "Cannot stat file %s: %s\n", filename, strerror(errno));
     return NULL;
   }