Re: [PATCH v8 1/4] worktree: remove extra members from struct add_opts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 23, 2018 at 3:38 PM, Thomas Gummerer <t.gummerer@xxxxxxxxx> wrote:
> There are two members of 'struct add_opts', which are only used inside
> the 'add()' function, but being part of 'struct add_opts' they are
> needlessly also passed to the 'add_worktree' function.
>
> Make them local to the 'add()' function to make it clearer where they
> are used.
>
> Signed-off-by: Thomas Gummerer <t.gummerer@xxxxxxxxx>
> ---
> diff --git a/builtin/worktree.c b/builtin/worktree.c
> @@ -27,8 +27,6 @@ struct add_opts {
>         int keep_locked;
> -       const char *new_branch;
> -       int force_new_branch;
>  };
> @@ -395,33 +394,32 @@ static int add(int ac, const char **av, const char *prefix)
> -       if (ac < 2 && !opts.new_branch && !opts.detach) {
> +       if (ac < 2 && !new_branch && !opts.detach) {
>                 int n;
>                 const char *s = worktree_basename(path, &n);
> -               opts.new_branch = xstrndup(s, n);
> +               new_branch = xstrndup(s, n);

Sorry for not noticing this earlier, but when 'new_branch' was part of
'opts', this leaked xstrndup'd string was covered by the UNLEAK(opts)
at the end of the function. However, now that 'new_branch' is a
standalone variable, it needs its own UNLEAK().



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux