Hello,

Answering on the patch itself for now:

Mikhail Karpov, le sam. 07 nov. 2026 19:03:56 +0700, a ecrit:
> diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c
> index 9a17ddb..ef8d780 100644
> --- a/libnetfs/dir-lookup.c
> +++ b/libnetfs/dir-lookup.c
> @@ -224,14 +225,23 @@ netfs_S_dir_lookup (struct protid *dircred,
>         err = iohelp_create_empty_iouser (&user);
>         if (! err)
>           {
> -           newpi = netfs_make_protid (netfs_make_peropen (dnp, 0,
> -                                                          dircred->po),
> -                                      user);
> -           if (! newpi)
> -             {
> +           newpo = netfs_make_peropen (dnp, 0, dircred->po);
> +           if (! newpo)
> +             {
>                 err = errno;
>                 iohelp_free_iouser (user);
>               }
> +           else
> +             {
> +               newpi = netfs_make_protid (newpo, user);
> +               if (! newpi)
> +                 {
> +                   err = errno;
> +                   iohelp_free_iouser (user);

Mmm, we should probably be able to factorize iohelp_free_iouser (user);
by having at the exit place a if (user) iohelp_free_iouser (user); and
make the success path set user = NULL?

You'll then be able to use the simple-to-read

if (!err)
    err = do_something();

if (!err)
    err = do_something();

etc.

if (err)
    {
        errno = err
        goto out;
    }

> diff --git a/libnetfs/dir-mkfile.c b/libnetfs/dir-mkfile.c
> index 9036101..90f5b69 100644
> --- a/libnetfs/dir-mkfile.c
> +++ b/libnetfs/dir-mkfile.c
> +  *newfile = ports_get_right (newpi);
> +  *newfiletype = MACH_MSG_TYPE_MAKE_SEND;
> +  ports_port_deref (newpi);
> +
> + out:
> +  netfs_nput (np);
>    return err;
> +
> + release_newpo:
> +  netfs_release_peropen (newpo);
> +
> + free_user:
> +  iohelp_free_iouser (user);
> +  goto out;

When the error and success exit paths are shared, better use if (newpo)
and if (user)?

I have applied the libnetfs/file-exec.c and libnetfs/file-reparent.c
parts.

Thanks,
Samuel

Reply via email to