Re: [RFC PATCH 1/5] ref-filter: add objectsize:disk option
- From
Оля Тележная <olyatelezhnaya@gmail.com>
- Date
- Nov 20, 2018, 09:17 UTC
- Message-ID
- <CAL21BmmK_ZS=wuGXRLj=s0=dqMvUWFiLLBZWx5ymnFjyasX=sA@mail.gmail.com>
- In-Reply-To
- <xmqqwophyc9s.fsf@gitster-ct.c.googlers.com>
вт, 13 нояб. 2018 г. в 04:52, Junio C Hamano <gitster@pobox.com>:
Show 29 quoted lines
>
> Jeff King <peff@peff.net> writes:
>
> >> You mean something like
> >>
> >> v->s = xstrfmt("%"PRIdMAX, (intmax_t)oi->disk_size);
> >
> > I think elsewhere we simply use PRIuMAX for printing large sizes via
> > off_t; we know this value isn't going to be negative.
> >
> > I'm not opposed to PRIdMAX, which _is_ more accurate, but...
> >
> >> P.S.: I wondered whether we have precedent for PRIdMAX, as we used to use
> >> only PRIuMAX, but yes: JeffH's json-writer uses PRIdMAX.
> >
> > That's pretty recent. I won't be surprised if we have to do some
> > preprocessor trickery to handle that at some point. We have a PRIuMAX
> > fallback already. That comes from c4001d92be (Use off_t when we really
> > mean a file offset., 2007-03-06), but it's not clear to me if that was
> > motivated by a real platform or an over-abundance of caution.
> >
> > I'm OK with just using PRIdMAX as appropriate for now. It will serve as
> > a weather-balloon, and we can #define our way out of it later if need
> > be.
>
> I am OK if we avoid PRIdMAX and use PRIuMAX instead with a cast to
> the corresponding size in this codepath, as long as we properly
> handle negative oi.disk_size field, which may be telling some
> "unusual" condition to us.Maybe we want to change the type (from off_t to unsigned) directly in struct object_info? That will help us not to make additional checkings. Or, at least, I suggest to add check to oid_object_info_extended() so that this function will give a guarantee that the size is non-negative. That will make code cleaner (otherwise we need to add checks everywhere after oid_object_info_extended() usage).
Please, look at this one also [1]. Thanks a lot!
[1] https://public-inbox.org/git/CAL21BmnoZuRih3Ky66_Tk0PweD36eZ6=fbY3jGumRcSJ=Bc_pQ@mail.gmail.com/
> >