From: Oleg Verych <olecom@flower.upol.cz>
To: "Robert P. J. Day" <rpjday@mindspring.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][RFC] Extend "memparse" to allow a NULL return pointer value.
Date: Sun, 23 Sep 2007 22:52:08 +0200 [thread overview]
Message-ID: <E1IZYQy-0007zL-Us@flower> (raw)
In-Reply-To: <Pine.LNX.4.64.0709151217530.16440@localhost.localdomain>
* Sat, 15 Sep 2007 12:27:07 -0400 (EDT)
> Extend the memparse() routine to allow a caller to use NULL as the
> second parameter value if he has no interest in that returned value.
(not `he', but `it', even if `he', then better `callers' + `they')
> ---
>
> there appear to be quite a number of calls to "memparse" which have
> no use for the value returned in the second parameter (the current
> pointer after the successful parse), but which are still forced to
> supply a valid char** address since they have no choice but to accept
> that value coming back. in many cases, that value is accepted just
> before the end of the calling function, making it clear that the value
> is ignored entirely, anyway.
A posteriori value, stored in this pointer serves very important role: it
validates returned result. Caller must do this. But if programmer doesn't
know problems (see below), `must' melts down to `may'.
If you take a look at simple_strtoull(), it already doesn't care if this
pointer is NULL or not. (So patch is NULL :)
But take closer look. If it returns `0' (zero), it is not clear if this
zero was parsed or not, unless you can compare `ptr' and `retptr'.
Another case if entire string have no valid number to parse (see
strtol(3)).
This is problem of this particular function, that is copied form
ordinary C. For instance see <http://bugs.debian.org/431320>.
--
-o--=O`C
#oo'L O
<___=E M
next prev parent reply other threads:[~2007-09-23 20:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-15 16:27 Robert P. J. Day
2007-09-23 20:52 ` Oleg Verych [this message]
2007-10-02 18:47 ` Robert P. J. Day
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1IZYQy-0007zL-Us@flower \
--to=olecom@flower.upol.cz \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rpjday@mindspring.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®