From: Junio C Hamano Date: Thu, 26 Mar 2026 17:18:52 GMT Subject: Re: [PATCH 5/6] do not discard const: keep signature Message-ID: In-Reply-To: <9a90f93111ec54e5eb9675cb84ac1d70ad95e118.1774537954.git.git@grubix.eu> Michael J Gruber writes: > Here, while we do not mutate the struct itself, many other signatures > expect a non-const argument - possibly unnecessarily - so we opt to keep > the original signature by casting to non-const. > --- Sorry, but I do not understand the above description, or the code change. Doesn't bsearch() returns non-const "void *" pointer? Ah, the constness of the return value in C23 depends on the constness of pm->commits[] array, which inherits its constness from the constness of parameter pm to the function, and you cast the value we are going to return explicitly to a non-const pointer. OK. In the context of "C23 constness" patch series, that may be obvious to you, but I suspect a future reader who finds this single commit from the output of "git blame" or something would be puzzled unless we say this is about adjusting to C23 that makes bsearch() a qualifier-preserving function somewhere in the log message. > pseudo-merge.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/pseudo-merge.c b/pseudo-merge.c > index a2d5bd85f9..ac81792e65 100644 > --- a/pseudo-merge.c > +++ b/pseudo-merge.c > @@ -644,7 +644,7 @@ static struct pseudo_merge_commit *find_pseudo_merge(const struct pseudo_merge_m > if (!pm->commits_nr) > return NULL; > > - return bsearch(&pos, pm->commits, pm->commits_nr, > + return (struct pseudo_merge_commit *) bsearch(&pos, pm->commits, pm->commits_nr, > PSEUDO_MERGE_COMMIT_RAWSZ, pseudo_merge_commit_cmp); > }