]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
calc_hash(): do not apply modulo LOAD_SIZE
authorJakub Skokan <jakub.skokan@havefun.cz>
Mon, 25 Jun 2018 06:55:23 +0000 (08:55 +0200)
committerJakub Skokan <jakub.skokan@havefun.cz>
Wed, 24 Oct 2018 12:06:38 +0000 (14:06 +0200)
This will allow `calc_hash()` to be used for other purposes than
the loadavg implementation.

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
bindings.c

index 94f0ff7cb98ee4322c0fc8da9f5d865ae6c886e7..abe2ff4161f164152e98bba10146b41b08406ee9 100644 (file)
@@ -115,7 +115,7 @@ static int calc_hash(char *name)
                        hash ^= (x >> 24);
                hash &= ~x;
        }
-       return ((hash & 0x7fffffff) % LOAD_SIZE);
+       return (hash & 0x7fffffff);
 }
 
 struct load_node {
@@ -4841,7 +4841,7 @@ static int proc_loadavg_read(char *buf, size_t size, off_t offset,
                return read_file("/proc/loadavg", buf, size, d);
 
        prune_init_slice(cg);
-       hash = calc_hash(cg);
+       hash = calc_hash(cg) % LOAD_SIZE;
        n = locate_node(cg, hash);
 
        /* First time */