Re: [PATCH 12/12] refs/files-backend: drop const to fix strchr() warning
- From
Jeff King <peff@peff.net>
- Date
- Apr 2, 2026, 03:56 UTC
- Message-ID
- <20260402035640.GC3492642@coredump.intra.peff.net>
- In-Reply-To
- <xmqqzf3mtj5z.fsf@gitster.g>
On Wed, Apr 01, 2026 at 03:22:48PM -0700, Junio C Hamano wrote:
Show 17 quoted lines
> >> But there's a catch. We derive that source pointer by parsing the line > >> with parse_oid_hex_algop(), which requires a const pointer for its > >> out-parameter. We can work around that by teaching it to use our > >> CONST_OUTPARAM() trick, just like skip_prefix(). Note that unlike > >> skip_prefix(), the function is not inline, so we can't just wrap it > >> using the same name (otherwise the actual definition would expand the > >> macro, which breaks compilation). So we rename the actual function with > >> an "_impl" suffix, and callers will all use the macro. > > > > Fair. In fact, I was a bit torn with the other commits whether it's nice > > to reuse the same name. I guess what it buys us is that you cannot > > accidentally call the wrong function without the guardrails. Even though > > that's quite unlikely with the `_impl` suffix. > > I share the sentiment. If I were deciding the design, I'd even go > forcing the _impl suffix to everything, including the inline ones, > as I found the earlier "strip_prefix()" example already confusing.
OK. I think the _impl() is ugly, but the idea is that you never have to type it outside of the macro anyway. I'll switch to that for the others for consistency.
-Peff