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

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 10, 2009, 16:53 UTC
Message-ID
<alpine.DEB.1.00.0908101850570.8324@intel-tinevez-2-302>
In-Reply-To
<a3f15ee60908100917k2a2d6de7ndd5e4ddd1d926cc3@mail.gmail.com>
Hi,

[please cull the quoted text to what you are actually replying to. Thanks]

On Mon, 10 Aug 2009, Ryan Flynn wrote:
Show 11 quoted lines
> On Mon, Aug 10, 2009 at 8:24 AM, Johannes
> Schindelin<Johannes.Schindelin@gmx.de> wrote:
> >
> > static unsigned int digits_of_number(unsigned int number) {
> >     unsigned int result;
> >     for (result = 1; number; number /= 10, result++)
> >         ; /* do nothing */
> >     return result;
> > }
> 
> whoops, actually yours: digits_of_number(1) -> 2
static unsigned int digits(unsigned int number)
{
        unsigned int result;
        for (result = 1; (number /= 10); result++)
                ; /* do nothing */
        return result;
}
I'm sorry, I forgot the "something like this" in my mail.
This version is actually tested.
It has non-optimal runtime, but then, it does not really matter.

Ciao, Dscho

Previous: Ryan FlynnNext: Jeff Epler
Message 10 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.