From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.9 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id AA645203E3 for ; Tue, 26 Jul 2016 12:25:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754689AbcGZMZb (ORCPT ); Tue, 26 Jul 2016 08:25:31 -0400 Received: from mout.gmx.net ([212.227.15.19]:49435 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752723AbcGZMZ3 (ORCPT ); Tue, 26 Jul 2016 08:25:29 -0400 Received: from virtualbox ([37.24.142.100]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0M0gww-1bB2le3OhS-00unNR; Tue, 26 Jul 2016 14:25:08 +0200 Date: Tue, 26 Jul 2016 14:24:59 +0200 (CEST) From: Johannes Schindelin X-X-Sender: virtualbox@virtualbox To: Junio C Hamano cc: Jeff King , git@vger.kernel.org, Eric Sunshine , Johannes Sixt , Duy Nguyen , =?UTF-8?Q?Jakub_Nar=C4=99bski?= Subject: Re: [PATCH v4 02/16] Report bugs consistently In-Reply-To: Message-ID: References: <72d1d530bb0e3c96d3affd6679cb7c26026d8321.1469187652.git.johannes.schindelin@gmx.de> <20160725221700.GB14131@sigill.intra.peff.net> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K0:xgDmNuoNUkuxmxfvEefZB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KCBvwm6tTkavUSkOCjHy2qGt0N4W854iaswVuFgdFd7Oy/5AwyczBV+2P07GGqMeodi U0IF7onJIR3BAy8HKjMmmolqDGTdPi1Ps2HvHsKMkKyXUC+QT7z/8uDmKKNssn6FQtJcn0T32 4zSWZkHLXHvbWhAbN7HZu/uXRbyS1mkQ= Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Junio & Peff, On Mon, 25 Jul 2016, Junio C Hamano wrote: > Jeff King writes: > > > On Mon, Jul 25, 2016 at 02:44:25PM -0700, Junio C Hamano wrote: > > > >> > diff --git a/imap-send.c b/imap-send.c > >> > index db0fafe..67d67f8 100644 > >> > --- a/imap-send.c > >> > +++ b/imap-send.c > >> > @@ -506,12 +506,12 @@ static char *next_arg(char **s) > >> > > >> > static int nfsnprintf(char *buf, int blen, const char *fmt, ...) > >> > { > >> > - int ret; > >> > + int ret = -1; > >> > va_list va; > >> > > >> > va_start(va, fmt); > >> > if (blen <= 0 || (unsigned)(ret = vsnprintf(buf, blen, fmt, va)) >= (unsigned)blen) > >> > - die("Fatal: buffer too small. Please report a bug."); > >> > + die("BUG: buffer too small (%d < %d)", ret, blen); > >> > va_end(va); > >> > return ret; > >> > } > >> > >> If "you gave me this size but you need at least this much" is truly > >> worth reporting, then this is misleading (ret is shown as -1 but you > >> do not even know how much is necessary). In any case, this should > >> be done as a separate step anyway. > > > > Hrm, isn't "ret" going to be the necessary size? According to the > > standard, it should tell us how many bytes were needed, not "-1" (this > > is the "your vsnprintf is broken" case handled by the strbuf code). > > Yes. If blen <= 0, we do not even do vsnprintf() and that is why > Dscho added "int ret = -1" initialization; otherwise his new die() > would end up referencing uninitialized ret. Exactly. While I was fixing this bug message, it occurred to me that it makes little sense to ask a user to report a bug when it is unknown how small the buffer was and what would have been the desired buffer size. So I did a fly-by fix. However, it is true that this is completely outside the purpose of this patch series (in fact, most of this patch is completely outside the purpose, and I am regretting that dearly, as the patch series' submission already takes almost a month, and I only now get people to review the critical parts of the changes). So I simply backed out the more verbose message and *only* do the obvious thing: replace the "Fatal:" prefix by a "BUG:" one. > > I do think the numbers are reversed, though. It should be "blen < ret". > > That, too ;-) True. All the better that I reverted that part of the patch ;-) Ciao, Dscho