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>
This commit is contained in:
parent
a0378fb9b3
commit
d8548232ea
20
fs/d_path.c
20
fs/d_path.c
|
@ -8,14 +8,13 @@
|
||||||
#include <linux/prefetch.h>
|
#include <linux/prefetch.h>
|
||||||
#include "mount.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;
|
*buflen -= namelen;
|
||||||
if (*buflen < 0)
|
if (likely(*buflen >= 0)) {
|
||||||
return -ENAMETOOLONG;
|
*buffer -= namelen;
|
||||||
*buffer -= namelen;
|
memcpy(*buffer, str, namelen);
|
||||||
memcpy(*buffer, str, namelen);
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,11 +297,10 @@ char *simple_dname(struct dentry *dentry, char *buffer, int buflen)
|
||||||
{
|
{
|
||||||
char *end = buffer + buflen;
|
char *end = buffer + buflen;
|
||||||
/* these dentries are never renamed, so d_lock is not needed */
|
/* these dentries are never renamed, so d_lock is not needed */
|
||||||
if (prepend(&end, &buflen, " (deleted)", 11) ||
|
prepend(&end, &buflen, " (deleted)", 11);
|
||||||
prepend(&end, &buflen, dentry->d_name.name, dentry->d_name.len) ||
|
prepend(&end, &buflen, dentry->d_name.name, dentry->d_name.len);
|
||||||
prepend(&end, &buflen, "/", 1))
|
prepend(&end, &buflen, "/", 1);
|
||||||
end = ERR_PTR(-ENAMETOOLONG);
|
return buflen >= 0 ? end : ERR_PTR(-ENAMETOOLONG);
|
||||||
return end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue