Skip to content

Commit

Permalink
Ijar: remove spurious error message
Browse files Browse the repository at this point in the history
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 #2201

--
Change-Id: I40d1ee2bad8f3d03627c0b5c0bfd593bb5289d23
Reviewed-on: https://cr.bazel.build/7810
PiperOrigin-RevId: 141739581
MOS_MIGRATED_REVID=141739581
  • Loading branch information
laszlocsomor authored and katre committed Dec 12, 2016
1 parent 68e850f commit 9a4dffe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion third_party/ijar/platform_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions third_party/ijar/platform_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 2 additions & 0 deletions third_party/ijar/zip_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 9a4dffe

Please sign in to comment.