Skip to contentSkip to conversation

vfs: fix docstring of hash_name()

PATCH Superseded Jori Koolstra 2 participants 3 messages Mar 12 – Mar 18 VFS

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfs: fix docstring of hash_name()

The docstring of hash_name() is falsely reporting that it returns the component length, whereas it returns a pointer to the terminating '/' or NUL character in the pathname being resolved.

---
 fs/namei.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
fs/namei.c +7 -2
index 58f715f7657e..d020b077591b 100644
@@ -2437,8 +2437,13 @@ u64 hashlen_string(const void *salt, const char *name)
 EXPORT_SYMBOL(hashlen_string);
 
 /*
- * Calculate the length and hash of the path component, and
- * return the length as the result.
+ * hash_name - Calculate the length and hash of the path component
+ * @nd: the path resolution state
+ * @name: the pathname to read the component from
+ * @lastword: if the component fits in a single word, the component bytes,
+ * otherwise 0
+ *
+ * Returns: a pointer to the terminating '/' or NUL character in @name.
  */
 static inline const char *hash_name(struct nameidata *nd,
 				    const char *name,
Signature · 1 line
2.53.0
reviewer
#1 lore raw
Quoted 14 lines · Jori Koolstra

The docstring of hash_name() is falsely reporting that it returns the component length, whereas it returns a pointer to the terminating '/' or NUL character in the pathname being resolved.

---
 fs/namei.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
fs/namei.c +0 -0
index 58f715f7657e..d020b077591b 100644

fs/namei.c u64 hashlen_string(const void *salt, const char *name) · line 2444

Quoted 10 lines
fs/namei.c +5 -2
@@ -2437,8 +2437,13 @@ u64 hashlen_string(const void *salt, const char *name)
 EXPORT_SYMBOL(hashlen_string);
 
 /*
- * Calculate the length and hash of the path component, and
- * return the length as the result.
+ * hash_name - Calculate the length and hash of the path component
+ * @nd: the path resolution state
+ * @name: the pathname to read the component from
+ * @lastword: if the component fits in a single word, the component bytes,
+ * otherwise 0

The @lastword description is what the function does but not really the point of the parameter. I think more understandable description would be:
LAST_WORD_IS_DOT, LAST_WORD_IS_DOTDOT, or some other value depending on whether the component is '.', '..', or something else.

Otherwise the fix looks good.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#2 lore raw
Quoted 35 lines

Op 17-03-2026 09:43 CET schreef Jan Kara <[email protected]>:

Quoted 14 lines · Jori Koolstra

The docstring of hash_name() is falsely reporting that it returns the component length, whereas it returns a pointer to the terminating '/' or NUL character in the pathname being resolved.

---
 fs/namei.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
fs/namei.c +0 -0
index 58f715f7657e..d020b077591b 100644

fs/namei.c u64 hashlen_string(const void *salt, const char *name) · line 2444

Quoted 10 lines
fs/namei.c +5 -2
@@ -2437,8 +2437,13 @@ u64 hashlen_string(const void *salt, const char *name)
 EXPORT_SYMBOL(hashlen_string);
 
 /*
- * Calculate the length and hash of the path component, and
- * return the length as the result.
+ * hash_name - Calculate the length and hash of the path component
+ * @nd: the path resolution state
+ * @name: the pathname to read the component from
+ * @lastword: if the component fits in a single word, the component bytes,
+ * otherwise 0

The @lastword description is what the function does but not really the point of the parameter. I think more understandable description would be:
LAST_WORD_IS_DOT, LAST_WORD_IS_DOTDOT, or some other value depending on whether the component is '.', '..', or something else.

Quoted 1 line

Otherwise the fix looks good.

Thanks, Jan. I incorporated your suggestion and sent it again. I really appreciate it!

Quoted 5 lines

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR