From d561b441e82e1ce3a8ab78654cc4d526d38c8525 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 4 Oct 2003 21:31:09 -0700 Subject: [PATCH] [PATCH] sysv_hash() is cleanups From: Scharfe The sysvfs code was confusing. Rewrite it to be readable, and use the existing VFS helper for recalculating the hash instead of doing it all by hand. --- fs/sysv/namei.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index c24d0be87e74e..7d96c33771939 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c @@ -42,21 +42,12 @@ static int add_nondir(struct dentry *dentry, struct inode *inode) static int sysv_hash(struct dentry *dentry, struct qstr *qstr) { - unsigned long hash; - int i; - const unsigned char *name; - - i = SYSV_NAMELEN; - if (i >= qstr->len) - return 0; /* Truncate the name in place, avoids having to define a compare function. */ - qstr->len = i; - name = qstr->name; - hash = init_name_hash(); - while (i--) - hash = partial_name_hash(*name++, hash); - qstr->hash = end_name_hash(hash); + if (qstr->len > SYSV_NAMELEN) { + qstr->len = SYSV_NAMELEN; + qstr->hash = full_name_hash(qstr->name, qstr->len); + } return 0; } -- 2.53.0