Re: [PATCH v3 2/6] branch.c: replace `git_config()` with `git_config_get_string()`

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

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Tanay Abhra <tanayabh@xxxxxxxxx> writes:
>
>> -	if (cb.value)
>> -		strbuf_addstr(buf, cb.value);
>> +	strbuf_addstr(buf, v);
>> +	free((char*)v);
>
> In this cast, I smell an API mistake to insist an extra constness to
> the output parameter of git_config_get_string() in [3/4] of the
> previous series.  Unlike the underlying git_config_get_value(),
> which lets the caller peek into the internal cached copy, the caller
> of git_config_get_string() is given its own copy, and I do not
> offhand see a good reason to forbid the caller from modifying it.

Indeed. My suggestion to change the declaration of char * variables
actually seem like a workaround for an API mistake after reading this.

(well, actually, the declaration could be modified if we think it brings
any new safety, but that should be another topic)

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
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]