svn commit: r286601 - head/usr.bin/patch

Xin Li delphij at delphij.net
Mon Aug 10 23:20:48 UTC 2015


On 08/10/15 14:40, Ed Schouten wrote:
> Hi Xin,
> 
> 2015-08-10 23:31 GMT+02:00 Xin LI <delphij at 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 at delphij.net>    https://www.delphij.net/
FreeBSD - The Power to Serve!           Live free or die

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20150810/eacbb97a/attachment.bin>


More information about the svn-src-all mailing list