diff options
author | László Csomor <laszlocsomor@google.com> | 2016-12-12 09:59:38 +0000 |
---|---|---|
committer | John Cater <jcater@google.com> | 2016-12-12 20:35:19 +0000 |
commit | 9a4dffe435385dff9e9095be6c24834bd1d193da (patch) | |
tree | 0f1afce784d57f6d9a6ca2d53a7c90825a0b7e3d /third_party/ijar | |
parent | 68e850ff8df0e381bd224d9926b400b7320d4fb8 (diff) |
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
Diffstat (limited to 'third_party/ijar')
-rw-r--r-- | third_party/ijar/platform_utils.cc | 1 | ||||
-rw-r--r-- | third_party/ijar/platform_utils.h | 6 | ||||
-rw-r--r-- | third_party/ijar/zip_main.cc | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/third_party/ijar/platform_utils.cc b/third_party/ijar/platform_utils.cc index 9c00ccc63a..5eced72362 100644 --- a/third_party/ijar/platform_utils.cc +++ b/third_party/ijar/platform_utils.cc @@ -40,7 +40,6 @@ bool stat_file(const char* path, Stat* result) { #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 5d0eb6bfa8..fc522c3386 100644 --- a/third_party/ijar/platform_utils.h +++ b/third_party/ijar/platform_utils.h @@ -40,8 +40,10 @@ inline u4 stat_to_zipattr(const Stat& file_stat) { } // 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 13bcc69e8f..51aea54157 100644 --- a/third_party/ijar/zip_main.cc +++ b/third_party/ijar/zip_main.cc @@ -166,6 +166,7 @@ int add_file(std::unique_ptr<ZipBuilder> const &builder, char *file, 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 @@ int add_file(std::unique_ptr<ZipBuilder> const &builder, char *file, 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; } |