diff options
author | Gao Xiang <gaoxiang25@huawei.com> | 2018-09-19 13:49:09 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-20 12:25:36 +0200 |
commit | bdf30cef10558d2158952c27bd18c16fe72b58d5 (patch) | |
tree | 991d427572ffc9cd6085eb87c0a4698d9abc4512 | |
parent | 5fb76bb04216fdbbee3fec544a0c16e990fefdfb (diff) | |
download | linux-stable-bdf30cef10558d2158952c27bd18c16fe72b58d5.tar.gz linux-stable-bdf30cef10558d2158952c27bd18c16fe72b58d5.tar.bz2 linux-stable-bdf30cef10558d2158952c27bd18c16fe72b58d5.zip |
staging: erofs: add some comments for xattr subsystem
As Dan Carpenter pointed out, it is better to document what
return values of these callbacks in `struct xattr_iter_handlers'
mean and why it->ofs is increased regardless of success or
failure in `xattr_foreach'.
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/erofs/xattr.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c index 4942ca167957..7b1367e84cb5 100644 --- a/drivers/staging/erofs/xattr.c +++ b/drivers/staging/erofs/xattr.c @@ -109,6 +109,13 @@ static int init_inode_xattrs(struct inode *inode) return 0; } +/* + * the general idea for these return values is + * if 0 is returned, go on processing the current xattr; + * 1 (> 0) is returned, skip this round to process the next xattr; + * -err (< 0) is returned, an error (maybe ENOXATTR) occurred + * and need to be handled + */ struct xattr_iter_handlers { int (*entry)(struct xattr_iter *, struct erofs_xattr_entry *); int (*name)(struct xattr_iter *, unsigned int, char *, unsigned int); @@ -164,6 +171,10 @@ static int inline_xattr_iter_begin(struct xattr_iter *it, return vi->xattr_isize - xattr_header_sz; } +/* + * Regardless of success or failure, `xattr_foreach' will end up with + * `ofs' pointing to the next xattr item rather than an arbitrary position. + */ static int xattr_foreach(struct xattr_iter *it, const struct xattr_iter_handlers *op, unsigned int *tlimit) { @@ -255,7 +266,7 @@ static int xattr_foreach(struct xattr_iter *it, } out: - /* we assume that ofs is aligned with 4 bytes */ + /* xattrs should be 4-byte aligned (on-disk constraint) */ it->ofs = EROFS_XATTR_ALIGN(it->ofs); return err; } |