Re: [PATCH 1/1] vreportf(): avoid buffered write in favor of unbuffered one
- From
Jeff King <peff@peff.net>
- Date
- Oct 29, 2019, 14:32 UTC
- Message-ID
- <20191029143246.GA3683@sigill.intra.peff.net>
- In-Reply-To
- <nycvar.QRO.7.76.6.1910291510330.46@tvgsbejvaqbjf.bet>
On Tue, Oct 29, 2019 at 03:13:39PM +0100, Johannes Schindelin wrote:
Show 5 quoted lines
> > I'd recommend xsnprintf() here. If we have a prefix longer than our > > vreportf() buffer, I think a BUG() is the right outcome. > > But BUG_fl() calls vreportf(). I am worried about an infinite > recursion...
Good point. I think it would be OK in practice (BUG() gives its own length-limited prefix), but it's probably a good idea to err on the side of caution inside vreportf.
Show 6 quoted lines
> > I'd disagree here. Any caller sending an arbitrarily-large prefix is > > holding it wrong, and we'd probably want to know as soon as possible > > (and a BUG() is our best bet there). > > How about truncating already inside the prefix, then? It would miss the > entire error message... but at least it would print _something_...
Yeah, that might be OK. Hopefully missing the whole rest of the error message would cause some tests to fail.
You could also abort() after having written if we want to be more BUG()-like.
-Peff