mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gao Xiang <gaoxiang25@huawei.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Chao Yu <yuchao0@huawei.com>, <devel@driverdev.osuosl.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	<linux-erofs@lists.ozlabs.org>, "Miao Xie" <miaoxie@huawei.com>,
	Du Wei <weidu.du@huawei.com>, Gao Xiang <gaoxiang25@huawei.com>
Subject: [PATCH 5/6] staging: erofs: add some comments for xattr subsystem
Date: Wed, 19 Sep 2018 13:49:09 +0800	[thread overview]
Message-ID: <1537336150-90604-5-git-send-email-gaoxiang25@huawei.com> (raw)
In-Reply-To: <1537336150-90604-1-git-send-email-gaoxiang25@huawei.com>

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>
---
 drivers/staging/erofs/xattr.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
index 4942ca1..7b1367e 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;
 }
-- 
1.9.1


  parent reply	other threads:[~2018-09-19  5:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-19  5:49 [PATCH 1/6] staging: erofs: remove redundant CONFIG_EROFS_FS_XATTRs Gao Xiang
2018-09-19  5:49 ` [PATCH 2/6] staging: erofs: fold in `__update_workgrp_llen' Gao Xiang
2018-09-19 15:14   ` Chao Yu
2018-09-19  5:49 ` [PATCH 3/6] staging: erofs: drop multiref support temporarily Gao Xiang
2018-09-19 15:20   ` Chao Yu
2018-09-19  5:49 ` [PATCH 4/6] staging: erofs: cleanup `z_erofs_vle_normalaccess_readpages' Gao Xiang
2018-09-19 15:26   ` Chao Yu
2018-09-19 15:32     ` Gao Xiang
2018-09-19 15:40       ` Gao Xiang
2018-09-19 15:45       ` Chao Yu
2018-09-19 15:51         ` Gao Xiang
2018-09-19 16:06   ` [PATCH v2 " Gao Xiang
2018-09-20  1:29     ` Chao Yu
2018-09-19  5:49 ` Gao Xiang [this message]
2018-09-19 15:27   ` [PATCH 5/6] staging: erofs: add some comments for xattr subsystem Chao Yu
2018-09-19  5:49 ` [PATCH 6/6] staging: erofs: simplify return value of `xattr_foreach' Gao Xiang
2018-09-19 15:28   ` Chao Yu
2018-09-19 15:07 ` [PATCH 1/6] staging: erofs: remove redundant CONFIG_EROFS_FS_XATTRs Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1537336150-90604-5-git-send-email-gaoxiang25@huawei.com \
    --to=gaoxiang25@huawei.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=weidu.du@huawei.com \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®