From a5fe3a240b7bf15077b30bba1a205a8af27c5d2b Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 30 Nov 1997 10:24:54 +0000 Subject: (): Include if HAVE_INTTYPES_H. (hash_insert2): Cast inode number to uintmax_t; this prevents negative remainders if the inode number is negative and ino_t is longer than unsigned. --- src/cp-hash.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/cp-hash.c') diff --git a/src/cp-hash.c b/src/cp-hash.c index e9535d453..ee6d0f21e 100644 --- a/src/cp-hash.c +++ b/src/cp-hash.c @@ -18,6 +18,10 @@ Written by Torbjorn Granlund, Sweden (tege@sics.se). */ #include + +#if HAVE_INTTYPES_H +# include +#endif #include #include #include "system.h" @@ -121,7 +125,10 @@ static char * hash_insert2 (struct htab *ht, ino_t ino, dev_t dev, const char *node) { struct entry **hp, *ep2, *ep; - hp = &ht->hash[ino % ht->modulus]; + + /* The cast to uintmax_t prevents negative remainders if ino is negative. */ + hp = &ht->hash[(uintmax_t) ino % ht->modulus]; + ep2 = *hp; /* Collision? */ -- cgit v1.2.3-54-g00ecf