X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fhash.c;h=cf5ba90a08e13e5dec7ef4e6bf23d7e2347b749b;hb=0ed0cc6f9c30537bd74222fd99a41726d488dd37;hp=e5f2e0076d74153644ce7618a3ed465d7ef97c6d;hpb=6dfdb323612184529b4b83c1be914dda8262de47;p=tinc diff --git a/src/hash.c b/src/hash.c index e5f2e007..cf5ba90a 100644 --- a/src/hash.c +++ b/src/hash.c @@ -27,10 +27,12 @@ static uint32_t hash_function(const void *p, size_t len) { const uint8_t *q = p; uint32_t hash = 0; - while(len > 0) { + while(true) { for(int i = len > 4 ? 4 : len; --i;) hash += q[i] << (8 * i); hash *= 0x9e370001UL; // Golden ratio prime. + if(len <= 4) + break; len -= 4; } return hash;