lkml.org 
[lkml]   [2019]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 2/2] ceph: fix return of ceph_vxattrcb_layout
Date
Currently it returns -ERANGE if it thinks that the buffer won't fit, but
the function returns size_t which is unsigned. Fix it to just return the
length in this case like the other xattrs do, and rely on the caller to
handle the case where it won't fit in the destination buffer.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/ceph/xattr.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 359d3cbbb37b..23687e3819f5 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -62,8 +62,7 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
const char *pool_name;
const char *ns_field = " pool_namespace=";
char buf[128];
- size_t len, total_len = 0;
- int ret;
+ size_t ret, len, total_len = 0;

pool_ns = ceph_try_get_string(ci->i_layout.pool_ns);

@@ -87,11 +86,8 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
if (pool_ns)
total_len += strlen(ns_field) + pool_ns->len;

- if (!size) {
- ret = total_len;
- } else if (total_len > size) {
- ret = -ERANGE;
- } else {
+ ret = total_len;
+ if (size >= total_len) {
memcpy(val, buf, len);
ret = len;
if (pool_name) {
--
2.21.0
\
 
 \ /
  Last update: 2019-06-21 16:19    [W:0.077 / U:8.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site