diff options
author | Evan Martin <martine@danga.com> | 2013-04-09 17:35:24 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2013-04-09 17:35:24 (GMT) |
commit | 0bdf68607c5f381376bc8c2b0ddb1d80eac6aaa2 (patch) | |
tree | 52ba0f857fc4225b226a539fb7d8147e56ffbe19 /src/deps_log.cc | |
parent | 3e5dce7ce641c600384268db3feb74cb8aac25b3 (diff) | |
parent | eee4910fb7189773074e4c89d4ba249704ba5d11 (diff) | |
download | Ninja-0bdf68607c5f381376bc8c2b0ddb1d80eac6aaa2.zip Ninja-0bdf68607c5f381376bc8c2b0ddb1d80eac6aaa2.tar.gz Ninja-0bdf68607c5f381376bc8c2b0ddb1d80eac6aaa2.tar.bz2 |
Merge pull request #534 from nico/invalid_log
On invalid depslog header, restart build instead of showing an error.
Diffstat (limited to 'src/deps_log.cc')
-rw-r--r-- | src/deps_log.cc | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/deps_log.cc b/src/deps_log.cc index 8946e32..79daba5 100644 --- a/src/deps_log.cc +++ b/src/deps_log.cc @@ -136,16 +136,12 @@ bool DepsLog::Load(const string& path, State* state, string* err) { return false; } - if (!fgets(buf, sizeof(buf), f)) { - *err = strerror(errno); - return false; - } + bool valid_header = true; int version = 0; - if (fread(&version, 4, 1, f) < 1) { - *err = strerror(errno); - return false; - } - if (version != kCurrentVersion) { + if (!fgets(buf, sizeof(buf), f) || fread(&version, 4, 1, f) < 1) + valid_header = false; + if (!valid_header || strcmp(buf, kFileSignature) != 0 || + version != kCurrentVersion) { *err = "bad deps log signature or version; starting over"; fclose(f); unlink(path.c_str()); |