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

Re: [PATCH] fix potential infinite loop given large unsigned integer

From
Christian Couder <chriscool@tuxfamily.org>
Date
Aug 10, 2009, 05:24 UTC
Message-ID
<200908100724.53345.chriscool@tuxfamily.org>
In-Reply-To
<40aa078e0908090525h7b4d6efeh658e2edcfbe16c7e@mail.gmail.com>
On Sunday 09 August 2009, Erik Faye-Lund wrote:
Show 13 quoted lines
> On Sun, Aug 9, 2009 at 9:38 AM, Junio C Hamano<gitster@pobox.com> wrote:
> > +               static char num_buf[64];
> >                rev.total = total + start_number - 1;
> > +               sprintf(num_buf, "%d", rev.total);
> > +               rev.num_width = strlen(num_buf);
>
> how about
> rev.num_width = (int)log10((double)rev.total) + 1;
>
> hm?
>
> log10() appears to be C99, but can be emulated on earlier C-versions by
> doing #define log10(x) (log(x) / log(10.0))
That would mean linking with -lm?

Regards, Christian.

Previous: Erik Faye-LundNext: Erik Faye-Lund
Message 5 of 14 in “fix potential infinite loop given large unsigned integer”
  1. fix potential infinite loop given large unsigned integerRyan Flynn, Aug 9, 2009
  2. Junio C HamanoAug 9, 2009
  3. Junio C HamanoAug 9, 2009
  4. Erik Faye-LundAug 9, 2009
  5. Christian CouderAug 10, 2009
  6. Erik Faye-LundAug 10, 2009
  7. Johannes SchindelinAug 10, 2009
  8. Ryan FlynnAug 10, 2009
  9. Ryan FlynnAug 10, 2009
  10. Johannes SchindelinAug 10, 2009
  11. Jeff EplerAug 11, 2009
  12. Ryan FlynnAug 10, 2009
  13. Tony FinchAug 10, 2009
  14. Ryan FlynnAug 9, 2009

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.