public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug manual/16776] New: Endless loop in strtol example
@ 2014-03-29 16:01 olafvdspek at gmail dot com
  2014-04-28 16:37 ` [Bug manual/16776] " neleai at seznam dot cz
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: olafvdspek at gmail dot com @ 2014-03-29 16:01 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16776

            Bug ID: 16776
           Summary: Endless loop in strtol example
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: manual
          Assignee: unassigned at sourceware dot org
          Reporter: olafvdspek at gmail dot com
                CC: mtk.manpages at gmail dot com, roland at gnu dot org

http://www.gnu.org/software/libc/manual/html_node/Parsing-of-Integers.html

Endless loop for sum_ints_from_string("garbage");

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug manual/16776] Endless loop in strtol example
  2014-03-29 16:01 [Bug manual/16776] New: Endless loop in strtol example olafvdspek at gmail dot com
@ 2014-04-28 16:37 ` neleai at seznam dot cz
  2014-04-28 18:46 ` olafvdspek at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: neleai at seznam dot cz @ 2014-04-28 16:37 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16776

Ondrej Bilka <neleai at seznam dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |neleai at seznam dot cz
         Resolution|---                         |INVALID

--- Comment #1 from Ondrej Bilka <neleai at seznam dot cz> ---
It is just example, clarity there is preferred.

It does not handle input validation, you need to supply valid input. For user
input you should use scanf anyway to handle thousand separators and such.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug manual/16776] Endless loop in strtol example
  2014-03-29 16:01 [Bug manual/16776] New: Endless loop in strtol example olafvdspek at gmail dot com
  2014-04-28 16:37 ` [Bug manual/16776] " neleai at seznam dot cz
@ 2014-04-28 18:46 ` olafvdspek at gmail dot com
  2014-04-30  3:55 ` mtk.manpages at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: olafvdspek at gmail dot com @ 2014-04-28 18:46 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16776

Olaf van der Spek <olafvdspek at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from Olaf van der Spek <olafvdspek at gmail dot com> ---
Bugs in examples are bad, they *will* be copied into real code.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug manual/16776] Endless loop in strtol example
  2014-03-29 16:01 [Bug manual/16776] New: Endless loop in strtol example olafvdspek at gmail dot com
  2014-04-28 16:37 ` [Bug manual/16776] " neleai at seznam dot cz
  2014-04-28 18:46 ` olafvdspek at gmail dot com
@ 2014-04-30  3:55 ` mtk.manpages at gmail dot com
  2014-04-30  7:16 ` olafvdspek at gmail dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mtk.manpages at gmail dot com @ 2014-04-30  3:55 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16776

--- Comment #3 from Michael Kerrisk <mtk.manpages at gmail dot com> ---
(In reply to Olaf van der Spek from comment #2)
> Bugs in examples are bad, they *will* be copied into real code.

I'mquite agree. 

But, Olaf, why not just provide a patch? Seems to me the solution is just an
API of the form:

int sum_ints_from_string(char * str, int &result)

which returns 0 on failure, 1 on success.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug manual/16776] Endless loop in strtol example
  2014-03-29 16:01 [Bug manual/16776] New: Endless loop in strtol example olafvdspek at gmail dot com
                   ` (2 preceding siblings ...)
  2014-04-30  3:55 ` mtk.manpages at gmail dot com
@ 2014-04-30  7:16 ` olafvdspek at gmail dot com
  2014-04-30  7:28 ` mtk.manpages at gmail dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: olafvdspek at gmail dot com @ 2014-04-30  7:16 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16776

--- Comment #4 from Olaf van der Spek <olafvdspek at gmail dot com> ---
On Wed, Apr 30, 2014 at 5:55 AM, mtk.manpages at gmail dot com
<sourceware-bugzilla@sourceware.org> wrote:
> https://sourceware.org/bugzilla/show_bug.cgi?id=16776
>
> --- Comment #3 from Michael Kerrisk <mtk.manpages at gmail dot com> ---
> (In reply to Olaf van der Spek from comment #2)
>> Bugs in examples are bad, they *will* be copied into real code.
>
> I'mquite agree.
>
> But, Olaf, why not just provide a patch?

On the mailing list I was trying to argue that strtol usage is too
hard to get right and this is one example of that.
I requested a new API but it was rejected. Now I'm curious how glibc
developers will handle this correctly.

> int sum_ints_from_string(char * str, int &result)

&? This isn't C++ is it?

which returns 0 on failure, 1 on success.

That's the opposite of normal.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug manual/16776] Endless loop in strtol example
  2014-03-29 16:01 [Bug manual/16776] New: Endless loop in strtol example olafvdspek at gmail dot com
                   ` (3 preceding siblings ...)
  2014-04-30  7:16 ` olafvdspek at gmail dot com
@ 2014-04-30  7:28 ` mtk.manpages at gmail dot com
  2014-06-12 19:51 ` fweimer at redhat dot com
  2014-06-13  9:16 ` fweimer at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: mtk.manpages at gmail dot com @ 2014-04-30  7:28 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16776

--- Comment #5 from Michael Kerrisk <mtk.manpages at gmail dot com> ---
(In reply to Olaf van der Spek from comment #4)
> On Wed, Apr 30, 2014 at 5:55 AM, mtk.manpages at gmail dot com
> <sourceware-bugzilla@sourceware.org> wrote:
> > https://sourceware.org/bugzilla/show_bug.cgi?id=16776
> >
> > --- Comment #3 from Michael Kerrisk <mtk.manpages at gmail dot com> ---
> > (In reply to Olaf van der Spek from comment #2)
> >> Bugs in examples are bad, they *will* be copied into real code.
> >
> > I'mquite agree.
> >
> > But, Olaf, why not just provide a patch?
> 
> On the mailing list I was trying to argue that strtol usage is too
> hard to get right and this is one example of that.
> I requested a new API but it was rejected. Now I'm curious how glibc
> developers will handle this correctly.
> 
> > int sum_ints_from_string(char * str, int &result)
> 
> &? This isn't C++ is it?
> 
> which returns 0 on failure, 1 on success.
> 
> That's the opposite of normal.

Olaf, why did you raise this bug? Either you care about seeing the documention
fixed or you do not. 

Rather than just complaining, and expecting someone else to fix it, it would be
more constructive to propose a patch that fixes the problem. I can't help but
feel a little irritated that when I point that out, you digress into quibling
about details^Werrors of language syntax and relative API choices.

(And, yes, strtol() is not the most comfortable API, but the example can be
corrected using that API.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug manual/16776] Endless loop in strtol example
  2014-03-29 16:01 [Bug manual/16776] New: Endless loop in strtol example olafvdspek at gmail dot com
                   ` (4 preceding siblings ...)
  2014-04-30  7:28 ` mtk.manpages at gmail dot com
@ 2014-06-12 19:51 ` fweimer at redhat dot com
  2014-06-13  9:16 ` fweimer at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: fweimer at redhat dot com @ 2014-06-12 19:51 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16776

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug manual/16776] Endless loop in strtol example
  2014-03-29 16:01 [Bug manual/16776] New: Endless loop in strtol example olafvdspek at gmail dot com
                   ` (5 preceding siblings ...)
  2014-06-12 19:51 ` fweimer at redhat dot com
@ 2014-06-13  9:16 ` fweimer at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13  9:16 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16776

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-13  9:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-29 16:01 [Bug manual/16776] New: Endless loop in strtol example olafvdspek at gmail dot com
2014-04-28 16:37 ` [Bug manual/16776] " neleai at seznam dot cz
2014-04-28 18:46 ` olafvdspek at gmail dot com
2014-04-30  3:55 ` mtk.manpages at gmail dot com
2014-04-30  7:16 ` olafvdspek at gmail dot com
2014-04-30  7:28 ` mtk.manpages at gmail dot com
2014-06-12 19:51 ` fweimer at redhat dot com
2014-06-13  9:16 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).