From: Junio C Hamano Date: Wed, 29 May 2024 17:28:05 GMT Subject: Re: [PATCH 03/19] global: convert intentionally-leaking config strings to consts Message-ID: In-Reply-To: <8f3decbb762916a536ec7a8d319c5903bd8f30c1.1716983704.git.ps@pks.im> Patrick Steinhardt writes: > There are multiple cases where we intentionally leak config strings: > > - `struct gpg_format` is used to track programs that can be used for > signing commits, either via gpg(1), gpgsm(1) or ssh-keygen(1). The > user can override the commands via several config variables. As the > array is populated once, only, and will never be free'd, it is fine > to treat the program as a quasi-constant. > > - `struct ll_merge_driver` is used to track merge drivers. Same as > with the GPG format, these drivers are populated once and then > reused. Its data is never free'd, either. > > - `struct userdiff_funcname` and `struct userdiff_driver` can be > configured via `diff..*` to add additional drivers. Again, > these have a global lifetime and are never free'd. > > All of these are intentionally kept alive and never free'd. Let's mark > the respective fields as `const char *` and cast away the constness when > assigning those values. It is not unclear where the linkage between "not freed" and "must be const" comes from. What am I missing? Thanks.