[PATCH 2/3] cache: use size_t for string lengths

John Keeping john at keeping.me.uk
Sat Jan 16 12:03:06 CET 2016


Avoid integer truncation on 64-bit systems.

Coverity-id: 13864
Signed-off-by: John Keeping <john at keeping.me.uk>
---
 cache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cache.c b/cache.c
index b169d20..df1b4a3 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)
-- 
2.7.0.226.gfe986fe



More information about the CGit mailing list