]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
d_path: don't bother with return value of prepend()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 18 May 2021 02:05:23 +0000 (22:05 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 19 May 2021 00:08:11 +0000 (20:08 -0400)
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>
fs/d_path.c

index 311d432875727283d0d8fde4f27c0fb11f3e370d..72b8087aaf9c3d6cb4a62ed5ef407734a80ca875 100644 (file)
@@ -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);
 }
 
 /*