Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Mar 2003 20:57:40 -0800
From:      Tim Kientzle <kientzle@acm.org>
To:        FreeBSD-Hackers <FreeBSD-Hackers@FreeBSD.ORG>
Subject:   Incorrect declarations for exec*
Message-ID:  <3E7FE1C4.3040104@acm.org>

next in thread | raw e-mail | index | archive | help
I believe the exec* functions are
declared incorrectly.  Unless I'm mistaken,
execve should be declared as

int
execve(const char *path, const char *const argv[], const char *const envp[]);

rather than

int
execve(const char *path, char *const argv[], char *const envp[]);

(Note the additional 'const' for argv and envp.)
Without this, there's no completely correct way to
build an argv or envp array with constant strings,
since you end up discarding a const somewhere along
the way.  Similar edits should be done to the other
exec* declarations.

Yes, GCC complains either way, since it (erroneously)
warns about adding const-ness in a pointer assignment.
(But only if you routinely use '-pedantic', which I
doubt many people do. ;-)

Tim Kientzle



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E7FE1C4.3040104>