Re: [PATCH 2/6] config: add 'git_config_string' to refactor string config variables.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Feb 16, 2008 at 07:21:42PM +0100, Christian Couder wrote:

> Well, in many places where this function could be used the dest string is 
> a "const char *" and in many other places it's a "char *", but it feels 
> safer to try to promote the latter into the former (like I did in the 
> following patches) rather than the other way around.

Hrm. I suppose that is true if you are talking about removing the
'const' from existing variables (which although pointing to non-const
allocated space in this instance, may in other code paths point to
actual const space).

But this is really a matter of C handling this poorly, because we have
to pass in a pointer rather than using the return value. So I think the
method that best reflects the desired behavior would be to actually cast
"const char *" to "char *" at the callsite. But unfortunately casts in C
are error-prone themselves, and make the code a little harder to read.

So perhaps your solution is a reasonable compromise.

-Peff
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux