Date: Mon, 21 Jul 2003 08:53:53 -0700 From: Tim Kientzle <kientzle@acm.org> To: Leo Bicknell <bicknell@ufp.org> Cc: hackers@freebsd.org Subject: Re: Correct way to call execve? Message-ID: <3F1C0C91.6050203@acm.org> References: <3F1B0610.90803@acm.org> <20030720225041.GA26277@ussenterprise.ufp.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Leo Bicknell wrote: > In a message written on Sun, Jul 20, 2003 at 02:13:52PM -0700, Tim Kientzle wrote: >>If I declare argv as "const char *", >>then the call to execve() warns about >>"incompatible pointer type" for the >>second argument. > > Almost, but the other order is important here, this passes gcc -Wall: > > #include <unistd.h> > #include <paths.h> > > int main(int argc, char *const argv[], char *const envp[]) { > char *const execargv[] = { _PATH_BSHELL, NULL }; > > execve(_PATH_BSHELL,execargv,envp); > > return 0; > } 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. I honestly don't believe it is possible to call execve() in a const-correct fashion with -Wwrite-strings unless you copy over all of the arguments into non-const storage. <sigh> I'd love to be proven wrong, though. Tim Kientzle
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F1C0C91.6050203>