From 5b004a0529bb98c853fe1bd6f63d12c965216799 Mon Sep 17 00:00:00 2001 From: Chiaki ISHIKAWA Date: Thu, 19 Mar 2015 00:55:04 +0900 Subject: [PATCH] Bug 11157 - Always check the result of stat() system call --- ccache.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ccache.c b/ccache.c index 5e904d8..ea7c77e 100644 --- a/ccache.c +++ b/ccache.c @@ -767,8 +767,12 @@ void update_manifest_file(void) if (manifest_put(manifest_path, cached_obj_hash, included_files)) { cc_log("Added object file hash to %s", manifest_path); update_mtime(manifest_path); - stat(manifest_path, &st); - stats_update_size(file_size(&st) - old_size, old_size == 0 ? 1 : 0); + if (stat(manifest_path, &st) == 0) { + stats_update_size(file_size(&st) - old_size, old_size == 0 ? 1 : 0); + } else { + cc_log("Failed to stat %s: %s", + manifest_path, strerror(errno)); + } } else { cc_log("Failed to add object file hash to %s", manifest_path); } @@ -916,9 +920,20 @@ to_cache(struct args *args) } cc_log("Stored in cache: %s", cached_stderr); if (conf->compression) { - stat(cached_stderr, &st); + /* + * The file was compressed, so obtain the compressed + * size again. + * + */ + if ( stat(cached_stderr, &st) == 0) { + stats_update_size(file_size(&st), 1); + } else { + cc_log("Failed to stat %s: %s", + cached_stderr, strerror(errno)); + } + } else { + stats_update_size(file_size(&st), 1); } - stats_update_size(file_size(&st), 1); } else { tmp_unlink(tmp_stderr); if (conf->recache) { -- 2.1.4