aboutsummaryrefslogtreecommitdiffstats
path: root/cache.c
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-02-08 13:55:06 +0100
committerlookshe <github@lookshe.org>2016-02-08 13:55:06 +0100
commita4d069bbd96810a7e3efc0d32c2889c83b9747e3 (patch)
tree88e2c697e31ea52aa0dba83e272d43e63eca9ad5 /cache.c
parent1ca23059758b5d1af843aa62a4aeb5de5b6bd5c8 (diff)
parent23f7dadaaba2817c92c42c0a642a3186aa8ef24d (diff)
Merge branch 'master' into flatten_tree
Diffstat (limited to 'cache.c')
-rw-r--r--cache.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/cache.c b/cache.c
index b169d20..6736a01 100644
--- a/cache.c
+++ b/cache.c
@@ -24,7 +24,7 @@
struct cache_slot {
const char *key;
- int keylen;
+ size_t keylen;
int ttl;
cache_fill_fn fn;
int cache_fd;
@@ -44,7 +44,7 @@ struct cache_slot {
static int open_slot(struct cache_slot *slot)
{
char *bufz;
- int bufkeylen = -1;
+ ssize_t bufkeylen = -1;
slot->cache_fd = open(slot->cache_name, O_RDONLY);
if (slot->cache_fd == -1)
@@ -61,8 +61,9 @@ static int open_slot(struct cache_slot *slot)
if (bufz)
bufkeylen = bufz - slot->buf;
- slot->match = bufkeylen == slot->keylen &&
- !memcmp(slot->key, slot->buf, bufkeylen + 1);
+ if (slot->key)
+ slot->match = bufkeylen == slot->keylen &&
+ !memcmp(slot->key, slot->buf, bufkeylen + 1);
return 0;
}