Re: [PATCH v2] refs: add GIT_TRACE_REFS debugging mechanism

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

 



On Tue, Sep 8, 2020 at 11:15 PM Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Cute.  I like it.

thanks :)

> > +     res = malloc(sizeof(struct debug_ref_store));
> > +     be_copy = malloc(sizeof(*be_copy));
>
> Not xmalloc() and friends?

done.

>
> > +     *be_copy = refs_be_debug;
> > +     be_copy->name = store->be->name;
>
> I guess we never destroy the ref-store instances so it is OK to
> assume that it would not cause problems later by sharing pieces of
> memory with underlying "real" thing like this.

correct. But changed to xstrdup to avoid confusion.

> > +     char o[200] = "null";
> > +     char n[200] = "null";
>
> I thought we had better constant than 200 (later you use 100 in the

done.

> same patch).  I am not sure how I feel about "null"; all places in
> Git, we tend to use 0{length-of-the-hash} for "no object name on
> this side", I think.

Some functions take NULL as a legitimate parameter, eg. a transaction
update with NULL as old OID (don't check old OID) is different from an
update with 0{40} as old OID. (ref must not exist yet).

> > +     for (int i = 0; i < transaction->nr; i++) {
>
> We still do not allow variable decl inside the set-up part of a
> for(;;) statement, if I recall Documentation/CodingGuidelines
> correctly.

Fixed.

> > +static int debug_delete_refs(struct ref_store *ref_store, const char *msg,
> > +                          struct string_list *refnames, unsigned int flags)
> > +{
> > +     struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
> > +     int res =
> > +             drefs->refs->be->delete_refs(drefs->refs, msg, refnames, flags);
> > +     int i = 0;
>
> No need to initialize 'i' here.

Fixed.

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado




[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