summaryrefslogtreecommitdiff
path: root/fs/d_path.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2021-05-18 05:05:23 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2021-05-19 03:08:11 +0300
commitd8548232ea2858d1d130f3ac835185159d367caa (patch)
treef870a8f843dbf090500b509586da3f013dd9ab82 /fs/d_path.c
parenta0378fb9b33308fb4547f098c6281af8ab4b5fb5 (diff)
downloadlinux-d8548232ea2858d1d130f3ac835185159d367caa.tar.xz
d_path: don't bother with return value of prepend()
Only simple_dname() checks it, and there we can simply do those calls and check for overflow (by looking of negative buflen) in the end. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/d_path.c')
-rw-r--r--fs/d_path.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/fs/d_path.c b/fs/d_path.c
index 311d43287572..72b8087aaf9c 100644
--- a/fs/d_path.c
+++ b/fs/d_path.c
@@ -8,14 +8,13 @@
#include <linux/prefetch.h>
#include "mount.h"
-static int prepend(char **buffer, int *buflen, const char *str, int namelen)
+static void prepend(char **buffer, int *buflen, const char *str, int namelen)
{
*buflen -= namelen;
- if (*buflen < 0)
- return -ENAMETOOLONG;
- *buffer -= namelen;
- memcpy(*buffer, str, namelen);
- return 0;
+ if (likely(*buflen >= 0)) {
+ *buffer -= namelen;
+ memcpy(*buffer, str, namelen);
+ }
}
/**
@@ -298,11 +297,10 @@ char *simple_dname(struct dentry *dentry, char *buffer, int buflen)
{
char *end = buffer + buflen;
/* these dentries are never renamed, so d_lock is not needed */
- if (prepend(&end, &buflen, " (deleted)", 11) ||
- prepend(&end, &buflen, dentry->d_name.name, dentry->d_name.len) ||
- prepend(&end, &buflen, "/", 1))
- end = ERR_PTR(-ENAMETOOLONG);
- return end;
+ prepend(&end, &buflen, " (deleted)", 11);
+ prepend(&end, &buflen, dentry->d_name.name, dentry->d_name.len);
+ prepend(&end, &buflen, "/", 1);
+ return buflen >= 0 ? end : ERR_PTR(-ENAMETOOLONG);
}
/*