Re: [PATCH 1/4] remote: return non-const pointer from error_buf()
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jan 19, 2026, 06:33 UTC
- Message-ID
- <aW3QVkpPPHjKVNLC@pks.im>
- In-Reply-To
- <20260119051945.GA1991523@coredump.intra.peff.net>
On Mon, Jan 19, 2026 at 12:19:45AM -0500, Jeff King wrote:
Show 9 quoted lines
> We have an error_buf() helper that functions a bit like our error() > helper, but returns NULL instead of -1. Its return type is "const char > *", but this is overly restrictive. If we use the helper in a function > that returns non-const "char *", the compiler will complain about > the implicit cast from const to non-const. > > Meanwhile, the const in the helper is doing nothing useful, as it only > ever returns NULL. Let's drop the const, which will let us use it in > both types of function.
This function signature is indeed quite misleading, and I'd argue that it continues to be so even after the change. I guess the intent is to make it a bit easier to print an error in functions that return a string.
I'm not really a huge fan of this, but it's not a fault of this patch series, so let's read on.
Patrick