mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
d_path: make prepend_name() boolean
It returns only 0 or -ENAMETOOLONG and both callers only check if the result is negative. Might as well return true on success and false on failure... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
01a4428ee7
commit
95b55c42f6
12
fs/d_path.c
12
fs/d_path.c
@ -34,15 +34,15 @@ static void prepend(char **buffer, int *buflen, const char *str, int namelen)
|
|||||||
*
|
*
|
||||||
* Load acquire is needed to make sure that we see that terminating NUL.
|
* Load acquire is needed to make sure that we see that terminating NUL.
|
||||||
*/
|
*/
|
||||||
static int prepend_name(char **buffer, int *buflen, const struct qstr *name)
|
static bool prepend_name(char **buffer, int *buflen, const struct qstr *name)
|
||||||
{
|
{
|
||||||
const char *dname = smp_load_acquire(&name->name); /* ^^^ */
|
const char *dname = smp_load_acquire(&name->name); /* ^^^ */
|
||||||
u32 dlen = READ_ONCE(name->len);
|
u32 dlen = READ_ONCE(name->len);
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
*buflen -= dlen + 1;
|
*buflen -= dlen + 1;
|
||||||
if (*buflen < 0)
|
if (unlikely(*buflen < 0))
|
||||||
return -ENAMETOOLONG;
|
return false;
|
||||||
p = *buffer -= dlen + 1;
|
p = *buffer -= dlen + 1;
|
||||||
*p++ = '/';
|
*p++ = '/';
|
||||||
while (dlen--) {
|
while (dlen--) {
|
||||||
@ -51,7 +51,7 @@ static int prepend_name(char **buffer, int *buflen, const struct qstr *name)
|
|||||||
break;
|
break;
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
}
|
}
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,7 +127,7 @@ restart:
|
|||||||
}
|
}
|
||||||
parent = dentry->d_parent;
|
parent = dentry->d_parent;
|
||||||
prefetch(parent);
|
prefetch(parent);
|
||||||
if (unlikely(prepend_name(&bptr, &blen, &dentry->d_name) < 0))
|
if (!prepend_name(&bptr, &blen, &dentry->d_name))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
dentry = parent;
|
dentry = parent;
|
||||||
@ -305,7 +305,7 @@ restart:
|
|||||||
const struct dentry *parent = dentry->d_parent;
|
const struct dentry *parent = dentry->d_parent;
|
||||||
|
|
||||||
prefetch(parent);
|
prefetch(parent);
|
||||||
if (unlikely(prepend_name(&end, &len, &dentry->d_name) < 0))
|
if (!prepend_name(&end, &len, &dentry->d_name))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
dentry = parent;
|
dentry = parent;
|
||||||
|
Loading…
Reference in New Issue
Block a user