Date: Mon, 10 Aug 2015 16:20:46 -0700 From: Xin Li <delphij@delphij.net> To: Ed Schouten <ed@nuxi.nl>, Xin LI <delphij@freebsd.org> Cc: src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r286601 - head/usr.bin/patch Message-ID: <55C931CE.3030806@delphij.net> In-Reply-To: <CABh_MKk5uOupQx9farP3_5D1J0f-5fAt0EXqnhautx0TNm9AaA@mail.gmail.com> References: <201508102131.t7ALVo5J050735@repo.freebsd.org> <CABh_MKk5uOupQx9farP3_5D1J0f-5fAt0EXqnhautx0TNm9AaA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On 08/10/15 14:40, Ed Schouten wrote:
> Hi Xin,
>
> 2015-08-10 23:31 GMT+02:00 Xin LI <delphij@freebsd.org>:
>> + argp[0] = strdup(RCSDIFF);
>> + argp[1] = strdup(filename);
>> ...
>> + free(argp[1]);
>> + free(argp[0]);
>
>> + argp[0] = strdup(CHECKOUT);
>> + argp[1] = strdup("-l");
>> + argp[2] = strdup(filename);
>> ...
>> + free(argp[2]);
>> + free(argp[1]);
>> + free(argp[0]);
>
> 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.
>
> See the table close to the bottom of this article:
>
> 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 obvious?)
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,
--
Xin LI <delphij@delphij.net> https://www.delphij.net/
FreeBSD - The Power to Serve! Live free or die
[-- Attachment #2 --]
-----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-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55C931CE.3030806>
