From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 21 10:15:43 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0D67C37B401 for ; Mon, 21 Jul 2003 10:15:43 -0700 (PDT) Received: from colnta.issci.ca (mail.acns.AB.ca [142.179.151.95]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2D11043F75 for ; Mon, 21 Jul 2003 10:15:42 -0700 (PDT) (envelope-from davidc@colnta.issci.ca) Received: from colnta.issci.ca (localhost [127.0.0.1]) by colnta.issci.ca (8.12.9/8.12.9) with ESMTP id h6LHFcPR021818; Mon, 21 Jul 2003 11:15:38 -0600 (MDT) (envelope-from davidc@colnta.issci.ca) Received: (from davidc@localhost) by colnta.issci.ca (8.12.9/8.12.9/Submit) id h6LHFcGQ021817; Mon, 21 Jul 2003 11:15:38 -0600 (MDT) Date: Mon, 21 Jul 2003 11:15:38 -0600 From: Chad David To: Tim Kientzle , hackers@freebsd.org Message-ID: <20030721171538.GA21656@colnta.acns.ab.ca> Mail-Followup-To: Tim Kientzle , hackers@freebsd.org References: <3F1B0610.90803@acm.org> <20030720225041.GA26277@ussenterprise.ufp.org> <3F1C0C91.6050203@acm.org> <20030721165735.GA56766@ussenterprise.ufp.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030721165735.GA56766@ussenterprise.ufp.org> User-Agent: Mutt/1.5.1i Subject: Re: Correct way to call execve? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jul 2003 17:15:43 -0000 On Mon, Jul 21, 2003 at 12:57:35PM -0400, Leo Bicknell wrote: > 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 > #include > > 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. Try cc -Wwrite-strings -Wcast-qual exec.c. You cannot simply cast away a const. -- Chad David davidc@issci.ca www.FreeBSD.org davidc@freebsd.org ISSci Inc. Calgary, Alberta Canada