Re: [PATCH v3 02/11] setup: introduce startup_info->original_cwd

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

 



On Sat, Nov 27, 2021 at 2:39 AM Ævar Arnfjörð Bjarmason
<avarab@xxxxxxxxx> wrote:
>
>
> On Fri, Nov 26 2021, Elijah Newren via GitGitGadget wrote:
>
> > From: Elijah Newren <newren@xxxxxxxxx>
> > [...]
> > +     /*
> > +      * Get our worktree; we only protect the current working directory
> > +      * if it's in the worktree.
> > +      */
> > +     worktree = get_git_work_tree();
> > +     if (!worktree)
> > +             goto no_prevention_needed;
> > +
> > +     offset = dir_inside_of(startup_info->original_cwd, worktree);
> > +     if (offset >= 0) {
>
> Nit: Easier to read as:
>
>     offset = [...]
>     if (offset < 0)
>         return;
>
> I.e. the reader can skip that whole "offset >= 0" block and anything
> after if it <0, which also reduces the indentation. We run into the
> "return' below.

Whoops; the return should be inside the braces.  I'll fix.

> > +             /*
> > +              * If startup_info->original_cwd == worktree, that is already
> > +              * protected and we don't need original_cwd as a secondary
> > +              * protection measure.
> > +              */
> > +             if (!*(startup_info->original_cwd + offset))
> > +                     goto no_prevention_needed;
> > +
> > +             /*
> > +              * original_cwd was inside worktree; precompose it just as
> > +              * we do prefix so that built up paths will match
> > +              */
> > +             startup_info->original_cwd = \
>
> TIL you can use backslashes like that in C outside of macros, but it's
> not needed here, better without?

Line is too long without it, so better with it.

>
> > +                     precompose_string_if_needed(startup_info->original_cwd
> > +                                                 + offset);
> > +     }
> > +     return;




[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