fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Arvind Raghavan <raghavan.arvind@gmail.com>
Cc: fstests <fstests@vger.kernel.org>,
	Jayashree Mohan <jaya@cs.utexas.edu>,
	Vijay Chidambaram <vijay@cs.utexas.edu>
Subject: Re: [PATCH] src/fssum: Refactor recursive traversal
Date: Tue, 19 May 2020 07:58:23 +0300	[thread overview]
Message-ID: <CAOQ4uxiOQ_BjRX6Sz-URY8DJTuAERa9Ws64YJ18GV_1oaXA3xw@mail.gmail.com> (raw)
In-Reply-To: <20200518201551.2553-1-raghavan.arvind@gmail.com>

On Tue, May 19, 2020 at 1:30 AM Arvind Raghavan
<raghavan.arvind@gmail.com> wrote:
>
> Moves some logic from the recursive directory traversal into a helper
> function to make it easier to add support for regular files. Does not
> change functionality.
>

Arvind,

The main comment is that this patch by itself is not eligible for merging.
It should be part of a patch series.

One more tip for ease of review - don't mix re-factor with moving chunks
of code. I reviewed this patch by moving sum_one() below sum(), where
the chunk of code was before the re-factoring and using diff -w.
Check it out to see how easy it is to review.

There is not really a reason to put the sum_one() helper on top as it
anyway depends on forward declaration of sum(), so it can be the other
way around.

See a couple of minor suggestions below.

Thanks,
Amir.


> Signed-off-by: Arvind Raghavan <raghavan.arvind@gmail.com>
> Signed-off-by: Jayashree Mohan <jaya@cs.utexas.edu>
> Signed-off-by: Vijay Chidambaram <vijay@cs.utexas.edu>
> ---
>  src/fssum.c | 298 ++++++++++++++++++++++++++++------------------------
>  1 file changed, 162 insertions(+), 136 deletions(-)
>
> diff --git a/src/fssum.c b/src/fssum.c
> index 3d97a70b..f2325ae0 100644
> --- a/src/fssum.c
> +++ b/src/fssum.c
> @@ -502,6 +502,162 @@ malformed:
>                 excess_file(fn);
>  }
>
> +void
> +sum(int dirfd, int level, sum_t *dircs, char *path_prefix, char *path_in);
> +
> +void
> +sum_one(int dirfd, int level, sum_t *dircs, char *path_prefix,
> +               char *path_in, char *name) {
> +       sum_t cs;
> +       sum_t meta;
> +       int fd;
> +       int ret;
> +       int excl;
> +       char* path;
> +       struct stat64 st;
> +       sum_file_data_t sum_file_data = flags[FLAG_STRUCTURE] ?
> +                       sum_file_data_strict : sum_file_data_permissive;

It's silly to do that every "one". flags is global and doesn't change,
so sum_file_data may be global as well and set on main.
Do that before refactoring patch.

[...]

>
>                 ret = fchdir(dirfd);
>                 if (ret == -1) {
> @@ -571,130 +710,17 @@ sum(int dirfd, int level, sum_t *dircs, char *path_prefix, char *path_in)
>                 }
>                 ret = lstat64(namelist[i], &st);

If you change that to fstatat(dirfd, ... AT_SYMLINK_NOFOLLOW),
fchdir() above will not be needed.
that change you can do with the refactoring patch.

Thanks,
Amir.

      reply	other threads:[~2020-05-19  4:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18 20:15 [PATCH] src/fssum: Refactor recursive traversal Arvind Raghavan
2020-05-19  4:58 ` Amir Goldstein [this message]

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=CAOQ4uxiOQ_BjRX6Sz-URY8DJTuAERa9Ws64YJ18GV_1oaXA3xw@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=jaya@cs.utexas.edu \
    --cc=raghavan.arvind@gmail.com \
    --cc=vijay@cs.utexas.edu \
    /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;
as well as URLs for NNTP newsgroup(s).