Re: [PATCH v2 05/11] bisect--helper: introduce new `decide_next()` function

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

 



Hi,

El jue., 30 ene. 2020 a las 13:31, Johannes Schindelin
(<Johannes.Schindelin@xxxxxx>) escribió:
>
> Hi Miriam,
>
> On Tue, 28 Jan 2020, Miriam Rubio wrote:
>
> > diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
> > index 21de5c096c..826fcba2ed 100644
> > --- a/builtin/bisect--helper.c
> > +++ b/builtin/bisect--helper.c
> > @@ -291,26 +291,14 @@ static const char need_bisect_start_warning[] =
> >          "You then need to give me at least one %s and %s revision.\n"
> >          "You can use \"git bisect %s\" and \"git bisect %s\" for that.");
> >
> > -static int bisect_next_check(const struct bisect_terms *terms,
> > -                          const char *current_term)
> > +static int decide_next(const struct bisect_terms *terms,
> > +                    const char *current_term, int missing_good,
> > +                    int missing_bad)
> >  {
> > -     int missing_good = 1, missing_bad = 1, res = 0;
> > -     const char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad);
> > -     const char *good_glob = xstrfmt("%s-*", terms->term_good);
> > -
> > -     if (ref_exists(bad_ref))
> > -             missing_bad = 0;
> > -
> > -     for_each_glob_ref_in(mark_good, good_glob, "refs/bisect/",
> > -                          (void *) &missing_good);
> > -
> >       if (!missing_good && !missing_bad)
> > -             goto finish;
> > -
> > -     if (!current_term) {
> > -             res = -1;
> > -             goto finish;
> > -     }
> > +             return 0;
> > +     if (!current_term)
> > +             return -1;
> >  [...]
> > +
> > +static int bisect_next_check(const struct bisect_terms *terms,
> > +                          const char *current_term)
> > +{
> > +     int missing_good = 1, missing_bad = 1;
> > +     const char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad);
> > +     const char *good_glob = xstrfmt("%s-*", terms->term_good);
> > +
> > +     if (ref_exists(bad_ref))
> > +             missing_bad = 0;
> > +
> > +     for_each_glob_ref_in(mark_good, good_glob, "refs/bisect/",
> > +                          (void *) &missing_good);
> > +
> >       free((void *) good_glob);
> >       free((void *) bad_ref);
>
> I know this is not something you introduced, but while you are already in
> the neighborhood, why not fix the types of `bad_ref` and `good_glob`? The
> `xstrfmt()` function returns `char *` for a reason: so that you do not
> have to cast it when `free()`ing the memory.

Sure! I will fix this.
Thank you for reviewing.
Best,
Miriam

>
> Thanks,
> Dscho
>
> > -     return res;
> > +
> > +     return decide_next(terms, current_term, missing_good, missing_bad);
> >  }
> >
> >  static int get_terms(struct bisect_terms *terms)
> > --
> > 2.21.1 (Apple Git-122.3)
> >
> >




[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