From: Avi Kivity <avi@argo.co.il>
To: Francis Moreau <francis.moro@gmail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>, linux-kernel@vger.kernel.org
Subject: Re: memparse(), simple_strtoul() prototypes...
Date: Mon, 19 Feb 2007 16:05:01 +0200 [thread overview]
Message-ID: <45D9AE8D.4060300@argo.co.il> (raw)
In-Reply-To: <38b2ab8a0702190503n32caeab3j2c2139c71cb5a9c5@mail.gmail.com>
Francis Moreau wrote:
>> > unsigned long simple_strtoul(const char *cp, char **endp,unsigned
>> int base)
>
> hm, I don't get your point. I understand why we cast 'cp' into a (char
> *) but that's not my point. My point is why aren't all function
> parameters are not const ?
>
'cp' can be passed as const, because simple_strtoul() does not modify
it. 'endp' cannot be passed as const, because simple_strtoul() cannot
know whether the caller would want to modify the string or not.
Whichever way it is written, it is broken. If changed to 'const', it
would preclude the caller from modifying the string if one has a
non-const string. As written, it can silently convert a const string to
a non-const string. However, as written it is (a) standard conforming,
and (b) more useful.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2007-02-19 14:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-18 16:04 memparse(), simple_strtoul() prototypes Francis Moreau
2007-02-19 0:30 ` H. Peter Anvin
2007-02-19 13:03 ` Francis Moreau
2007-02-19 14:05 ` Avi Kivity [this message]
2007-02-20 8:19 ` Francis Moreau
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=45D9AE8D.4060300@argo.co.il \
--to=avi@argo.co.il \
--cc=francis.moro@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
/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