]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Removed time_of_compilation check wrt SLOPPY_FILE_STAT_MATCHES
authorAlexey Tourbin <alexey.tourbin@gmail.com>
Wed, 15 Feb 2017 00:25:49 +0000 (03:25 +0300)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 25 Mar 2017 19:16:42 +0000 (20:16 +0100)
The whole code seems to be a thinko.  For a hit, neither ctime
nor mtime should be greater than or equal to time_of_compilation.
The code only seems to work because time_of_compilation is 0
at this stage (i.e. has not been initialized).

While at it, I also introduce an optimization: when sizes do
not match, it's a good chance to bail out early; there is no
point in further hashing the file.

manifest.c

index 7c019e18395502e1f99ed222206653745b06fb73..b84cc55a1cc192d85357a870d06333b8a380f386 100644 (file)
@@ -377,14 +377,12 @@ verify_object(struct conf *conf, struct manifest *mf, struct object *obj,
                        hashtable_insert(stated_files, x_strdup(path), st);
                }
 
+               if (fi->size != st->size) {
+                       return 0;
+               }
+
                if (conf->sloppiness & SLOPPY_FILE_STAT_MATCHES) {
-                       // st->ctime is sometimes 0, so we can't check that both st->ctime and
-                       // st->mtime are greater than time_of_compilation. But it's sufficient to
-                       // check that either is.
-                       if (fi->size == st->size
-                           && fi->mtime == st->mtime
-                           && fi->ctime == st->ctime
-                           && MAX(st->mtime, st->ctime) >= time_of_compilation) {
+                       if (fi->mtime == st->mtime && fi->ctime == st->ctime) {
                                cc_log("size/mtime/ctime hit for %s", path);
                                continue;
                        } else {