summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@gnu.org>2015-03-05 23:12:58 +0100
committerAndreas Gruenbacher <agruen@gnu.org>2015-03-05 23:14:25 +0100
commit99d3b514e9421799b4496dda7a95c4eb099e7a43 (patch)
treed5855169af630dc6aec0f11b54fa358370b04f82
parenta6615bcb83b673082025db15ec323707f8305fa3 (diff)
downloadpatch-99d3b514e9421799b4496dda7a95c4eb099e7a43.tar.gz
Use overflow safe arithmetic for counting cache misses
* src/safe.c: We don't need a long counter if we use overflow-safe arithmetic here.
-rw-r--r--src/safe.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/safe.c b/src/safe.c
index de7f306..b6fef70 100644
--- a/src/safe.c
+++ b/src/safe.c
@@ -51,7 +51,7 @@ static const unsigned int MAX_PATH_COMPONENTS = 1024;
/* Path lookup results are cached in a hash table + LRU list. When the
cache is full, the oldest entries are removed. */
-unsigned long dirfd_cache_misses;
+unsigned int dirfd_cache_misses;
struct cached_dirfd {
struct list_head lru_link;
@@ -372,7 +372,7 @@ static int traverse_another_path (const char **pathname, int keepfd)
.fd = AT_FDCWD,
};
- unsigned long misses = dirfd_cache_misses;
+ unsigned int misses = dirfd_cache_misses;
const char *path = *pathname, *last;
struct cached_dirfd *dir = &cwd;
struct symlink *stack = NULL;
@@ -465,11 +465,11 @@ static int traverse_another_path (const char **pathname, int keepfd)
*pathname = last;
if (debug & 32)
{
- misses = dirfd_cache_misses - misses;
+ misses = (signed int) dirfd_cache_misses - (signed int) misses;
if (! misses)
printf(" (cached)\n");
else
- printf (" (%lu miss%s)\n", misses, misses == 1 ? "" : "es");
+ printf (" (%u miss%s)\n", misses, misses == 1 ? "" : "es");
fflush (stdout);
}
return put_path (dir);