Skip to contentSkip to conversation

libfs: return error code on failed attr set

PATCH In review Wu Fengguang 2 participants 3 messages Sep 11, 2009 – Sep 12, 2009 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libfs: return error code on failed attr set

Currently all simple_attr.set handlers return 0 on success and negative codes on error. Fix simple_attr_write() to return these error codes.

CC Theodore Ts'o <[email protected]>
CC Al Viro <[email protected]>
CC Christoph Hellwig <[email protected]>
CC Nick Piggin <[email protected]>
---
 fs/libfs.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/libfs.c +3 -2
@@ -822,10 +822,11 @@ ssize_t simple_attr_write(struct file *f
 	if (copy_from_user(attr->set_buf, buf, size))
 		goto out;
 
-	ret = len; /* claim we got the whole input */
 	attr->set_buf[size] = '\0';
 	val = simple_strtol(attr->set_buf, NULL, 0);
-	attr->set(attr->data, val);
+	ret = attr->set(attr->data, val);
+	if (ret == 0)
+		ret = len; /* on success, claim we got the whole input */
 out:
 	mutex_unlock(&attr->mutex);
 	return ret;
#1 lore raw
Quoted 2 lines · Wu Fengguang

Currently all simple_attr.set handlers return 0 on success and negative codes on error. Fix simple_attr_write() to return these error codes.

Looks good to me assuming you actually audited all the implementations to do the right thing.

#2 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Wu Fengguang

Currently all simple_attr.set handlers return 0 on success and negative codes on error. Fix simple_attr_write() to return these error codes.

Looks good to me assuming you actually audited all the implementations to do the right thing.

Yes I checked all DEFINE_SIMPLE_ATTRIBUTE users. All the _set() handlers returns 0 for success and negative error code for failure.

Thanks,
Fengguang