Re: [PATCH 6/5] grep.c: mark eol/bol and derived as "const char * const"
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 22, 2021, 19:02 UTC
- Message-ID
- <xmqqh7ec77s3.fsf@gitster.g>
- In-Reply-To
- <YUnx7gt0KQNRlhuZ@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 12 quoted lines
> On Tue, Sep 21, 2021 at 02:45:16PM +0200, Ævar Arnfjörð Bjarmason wrote: > >> I think that generally git's codebase could use going beyond just >> "const char *" when a "const char * const" would suffice, for some >> reason we seem to mostly use it for the static usage variables. > > I didn't dig up the references in the list archive, but I feel like > we've had this discussion long ago. One of the reasons not to do so is > that it pollutes the function's interface with internal details. The > caller does not care whether the function is going to modify the pointer > itself, because it is passed by value. You could apply the same logic > that we should be passing "const int", and so on.
Yes. "This pointer is not modified" is a good thing to have inside an implementation, but the callers should not have to care.
Thanks.