[PATCH v2 1/3] erofs-utils: lib: Add some comments about const-ness around iterate API
Kelvin Zhang
zhangkelvin at google.com
Wed Jan 5 10:37:51 AEDT 2022
friendly ping
On Tue, Dec 21, 2021 at 5:49 PM Kelvin Zhang <zhangkelvin at google.com> wrote:
>
> The new iterate dir API has non-trivial const correctness requirements.
> Document them in comment.
>
> Signed-off-by: Kelvin Zhang <zhangkelvin at google.com>
> ---
> include/erofs/dir.h | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/include/erofs/dir.h b/include/erofs/dir.h
> index 77656ca..59bd40d 100644
> --- a/include/erofs/dir.h
> +++ b/include/erofs/dir.h
> @@ -39,6 +39,14 @@ typedef int (*erofs_readdir_cb)(struct erofs_dir_context *);
> * the callback context. |de_namelen| is the exact dirent name length.
> */
> struct erofs_dir_context {
> + /* During execution of |erofs_iterate_dir|, the function needs
> + * to read the values inside |erofs_inode* dir|. So it is important
> + * that the callback function does not modify stuct pointed by
> + * |dir|. It is OK to repoint |dir| to other objects.
> + * Unfortunately, it's not possible to enforce this restriction
> + * with const keyword, as |erofs_iterate_dir| needs to modify
> + * struct pointed by |dir|.
> + */
> struct erofs_inode *dir;
> erofs_readdir_cb cb;
> erofs_nid_t pnid; /* optional */
> --
> 2.34.1.448.ga2b2bfdf31-goog
>
--
Sincerely,
Kelvin Zhang
More information about the Linux-erofs
mailing list