git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH 1/5] ref-filter: add objectsize:disk option

From
Jeff King <peff@peff.net>
Date
Nov 12, 2018, 13:12 UTC
Message-ID
<20181112131247.GL3956@sigill.intra.peff.net>
In-Reply-To
<nycvar.QRO.7.76.6.1811121300520.39@tvgsbejvaqbjf.bet>
On Mon, Nov 12, 2018 at 01:03:25PM +0100, Johannes Schindelin wrote:
Show 15 quoted lines
> > oi.disk_size is off_t; do we know "long long" 
> > 
> >    (1) is available widely enough (I think it is from c99)?
> > 
> >    (2) is sufficiently wide so that we can safely cast off_t to?
> > 
> >    (3) will stay to be sufficiently wide as machines get larger
> >        together with standard types like off_t in the future?
> > 
> > I'd rather use intmax_t (as off_t is a signed integral type) so that
> > we do not have to worry about these questions in the first place.
> 
> 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.

-Peff
Previous: Johannes SchindelinNext: Junio C Hamano
Message 9 of 15 in “ref-filter: add objectsize:disk option”
  1. 1/5 ref-filter: add objectsize:disk optionOlga Telezhnaya, Nov 9, 2018
  2. 3/5 ref-filter: add deltabase optionOlga Telezhnaya, Nov 9, 2018
  3. 4/5 ref-filter: add tests for deltabaseOlga Telezhnaya, Nov 9, 2018
  4. 2/5 ref-filter: add tests for objectsize:diskOlga Telezhnaya, Nov 9, 2018
  5. 5/5 ref-filter: add docs for new optionsOlga Telezhnaya, Nov 9, 2018
  6. Junio C HamanoNov 12, 2018
  7. Junio C HamanoNov 12, 2018
  8. Johannes SchindelinNov 12, 2018
  9. Jeff KingNov 12, 2018
  10. Junio C HamanoNov 13, 2018
  11. Оля ТележнаяNov 20, 2018
  12. Junio C HamanoNov 21, 2018
  13. Johannes SchindelinNov 22, 2018
  14. Junio C HamanoNov 24, 2018
  15. Jeff KingNov 12, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.