Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jul 2003 12:57:35 -0400
From:      Leo Bicknell <bicknell@ufp.org>
To:        Tim Kientzle <kientzle@acm.org>
Cc:        hackers@freebsd.org
Subject:   Re: Correct way to call execve?
Message-ID:  <20030721165735.GA56766@ussenterprise.ufp.org>
In-Reply-To: <3F1C0C91.6050203@acm.org>
References:  <3F1B0610.90803@acm.org> <20030720225041.GA26277@ussenterprise.ufp.org> <3F1C0C91.6050203@acm.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--SLDf9lqlvOQaIe6s
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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] =3D (char *)_PATH_BSHELL;
  execargv[1] =3D (char *)NULL;

  execve(_PATH_BSHELL,execargv,envp);

  return 0;
}
% cc -Wwrite-strings exec.c
% cc -Wall exec.c

Looks good to me.

--=20
       Leo Bicknell - bicknell@ufp.org - CCIE 3440
        PGP keys at http://www.ufp.org/~bicknell/
Read TMBG List - tmbg-list-request@tmbg.org, www.tmbg.org

--SLDf9lqlvOQaIe6s
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD4DBQE/HBt/Nh6mMG5yMTYRAireAKCGpkL4F+HaO2EtLIf0SkvxE+dINACVFkIC
CAF2RcO7TZpZJAmjuExIGQ==
=ymiB
-----END PGP SIGNATURE-----

--SLDf9lqlvOQaIe6s--



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