From owner-svn-src-head@freebsd.org Mon Aug 10 23:20:48 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7DCF699E1AF; Mon, 10 Aug 2015 23:20:48 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from anubis.delphij.net (anubis.delphij.net [IPv6:2001:470:1:117::25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "anubis.delphij.net", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 61CAEA13; Mon, 10 Aug 2015 23:20:48 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from zeta.ixsystems.com (unknown [12.229.62.2]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by anubis.delphij.net (Postfix) with ESMTPSA id 940EB12A97; Mon, 10 Aug 2015 16:20:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=delphij.net; s=anubis; t=1439248847; x=1439263247; bh=9UBZGGI/6RC3TgpceVcW8SBuiB5Ddct45Fp5rpZlcLM=; h=Reply-To:Subject:References:To:Cc:From:Date:In-Reply-To; b=e42HWr5deXbMeQPGpJJbdDZ++E0buLqM4xnXxjT7pxm8Hb7v4fGJI8T9qDIbYG5Nb 8r/LOu3eY1Kf0WqZ+l/xS653bnVn69kstyV4Qcj0oukHnOdipmP4VZhkysxDr960iV 7otjj+yA6tejspSqaSQEp2L/baTOpgg0HY2wU3Vs= Reply-To: d@delphij.net Subject: Re: svn commit: r286601 - head/usr.bin/patch References: <201508102131.t7ALVo5J050735@repo.freebsd.org> To: Ed Schouten , Xin LI Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Xin Li X-Enigmail-Draft-Status: N1210 Organization: The FreeBSD Project Message-ID: <55C931CE.3030806@delphij.net> Date: Mon, 10 Aug 2015 16:20:46 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2m1pghCR1O71M73RtjH9Obr4q41dvStdR" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Aug 2015 23:20:48 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2m1pghCR1O71M73RtjH9Obr4q41dvStdR Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/10/15 14:40, Ed Schouten wrote: > Hi Xin, >=20 > 2015-08-10 23:31 GMT+02:00 Xin LI : >> + argp[0] =3D strdup(RCSDIFF); >> + argp[1] =3D strdup(filename); >> ... >> + free(argp[1]); >> + free(argp[0]); >=20 >> + argp[0] =3D strdup(CHECKOUT); >> + argp[1] =3D strdup("-l"); >> + argp[2] =3D strdup(filename); >> ... >> + free(argp[2]); >> + free(argp[1]); >> + free(argp[0]); >=20 > There's no need to call strdup() here, right? As far as I know, > execve() and posix_spawn() don't modify the arguments/environment. > These functions should use "const char *const *" as its argument type, > but that cannot be used, as it would cause compiler errors if "char > **" is passed in. >=20 > See the table close to the bottom of this article: >=20 > http://pubs.opengroup.org/onlinepubs/9699919799/functions/execve.html Do you have a better solution for this? No, this is not ideal but I didn't find a better alternative (or maybe I have missed something obviou= s?) I think with the current POSIX definition of the interface, we have only two options: either strdup() or cast away const (I'd rather hide this kind of uglyness in the library), no? Cheers, --=20 Xin LI https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die --2m1pghCR1O71M73RtjH9Obr4q41dvStdR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.1.6 (FreeBSD) iQIcBAEBCgAGBQJVyTHPAAoJEJW2GBstM+nscR0P/3PcbThFReBG/GUM8Nof6VlW 00UoCwKvJAN400k81W86RxPphOEe7TJicsgHBmRpFtzrgf4NzST+vxK5evANQZdT WVWKUPoe5z+nDkAutB0CTmOjMdcegOwus/6lvm1IwZCJT7Qg0JOxn7MSR8CCjt+V WEgL0qlFA/PqAZMUKiPRG9AEYj1NnT85LZ0KbBJCKh/ziZYTlL5A72vhQ1XaTjgN KYOrM9gYqM/8sJM1oWvC7j8Dw3d9yL3HA4M1GxgvcnOAG408OyiFAweLGmhGfYSF AbDuDB0GeEV7Q0JIppzIaMV/oRzWpJqDaBcZhjAX4ITAITl94pYPlzcwOubBvYsi 3dS8VdgBkVDtwwA+cJNX9Sn7S2gxqzRVb9W0AutU3LIB6bkKquPXspJJ5aZ6h6EI GhJ+lbdM1odcihoL6PLssszw/k5hl1KXV0WRn742J0oj8bJErwgREW0PqysW7LWj Y5O3fNIEdsXcHOZS6yjVb4ieDn1LxzxpAWCtODT2rooXQ4jTBlHC3tsZjoVtr7vN mI0SeKbgz7I6qVR2hx62WID25uYaTiszUSc87u/A3cMexBmFzt3TcfXuwjtNCLV6 Wd7eNDYVqZ8T/Qop59Xi1gBzxwQvjul+0LeRLzZDIPDDbec1jpJKJNt6EUfQAhWe qnwwojBWSjZ9GFtrZBt2 =1p1Q -----END PGP SIGNATURE----- --2m1pghCR1O71M73RtjH9Obr4q41dvStdR--