Re: [PATCH] diff-lib: add idx/tree sanity check to oneway_diff
Jeff King <[email protected]> Tue, 28 Jul 2026 13:12:49 -0400
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jul 28, 2026 at 09:22:42AM -0700, Junio C Hamano wrote: > Jeff King <[email protected]> writes: > > >> We could help humans that the BUG is not expected to fire and only > >> to help static analysis by a crafted message, perhaps? > >> > >> if (!idx && !tree) > >> BUG("Hey, Coverity, this does not happen"); > > > > If we are helping humans we can probably afford to be a little more > > eloquent. ;) > > I do not mind eloquence but does the comment clearly say this is > primarily for unconfusing static analyzers? My first reaction to > the message was "OK, you explained very well why this condition > would never happen, but then why do you need to check and BUG() on > it???" I guess by the time I did all of the digging and thinking, my thought was that it _wasn't_ primarily for static analyzers, but to capture the output of that research. But then yeah, we don't really need the actual BUG(), but without it, it feels strange to even have the comment at all. I think that's why I waffled on sending the patch at all. > But I guess the point is a future modification may invalidate this, > in which case I agree with the comment. If it is hard for static > analysers to get it right, it probably is equally difficult to grok > for AI agents many people seem to be using to draft their changes > these days ;-). Yeah, I guess it may help them, too. :) -Peff