Correct way to call execve?
Leo Bicknell
bicknell at ufp.org
Mon Jul 21 09:57:43 PDT 2003
In a message written on Mon, Jul 21, 2003 at 08:53:53AM -0700, Tim Kientzle wrote:
> Actually, this example passes -Wall if you declare
> "execargv" as simply "char *[]". However, I'm looking
> for something that passes gcc -Wwrite-strings, which this
> example does not.
% cat exec.c
#include <unistd.h>
#include <paths.h>
int main(int argc, char *const argv[], char *const envp[]) {
char *execargv[2];
execargv[0] = (char *)_PATH_BSHELL;
execargv[1] = (char *)NULL;
execve(_PATH_BSHELL,execargv,envp);
return 0;
}
% cc -Wwrite-strings exec.c
% cc -Wall exec.c
Looks good to me.
--
Leo Bicknell - bicknell at ufp.org - CCIE 3440
PGP keys at http://www.ufp.org/~bicknell/
Read TMBG List - tmbg-list-request at tmbg.org, www.tmbg.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20030721/8d70c49c/attachment.bin
More information about the freebsd-hackers
mailing list