git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 2/2] built-in rebase: reinstate `checkout -q` behavior where appropriate
Date: Fri, 9 Nov 2018 14:59:34 -0500	[thread overview]
Message-ID: <20181109195934.GC4938@sigill.intra.peff.net> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.1811091813140.39@tvgsbejvaqbjf.bet>

On Fri, Nov 09, 2018 at 06:21:41PM +0100, Johannes Schindelin wrote:

> Actually, you got me thinking about the desc.buffer. And I think there is
> one corner case where it could cause a problem: `struct tree_desc desc[2]`
> does not initialize the buffers to NULL. And what if
> fill_tree_descriptor() function returns NULL? Then the buffer is still
> uninitialized.
> 
> In practice, our *current* version of fill_tree_descriptor() never returns
> NULL if the oid parameter is non-NULL. It would die() in the error case
> instead (bad!). So to prepare for a less bad version, I'd rather
> initialize the `desc` array and be on the safe (and easier to reason
> about) side.

Yeah, I agree with all of that.

One solution would just be to increment only after success:

  if (fill_tree_descriptor(&desc[nr], ..) < 0)
	goto error;
  nr++; /* now we know it's valid! */

But there are lots of alternatives.  :)

-Peff

  reply	other threads:[~2018-11-09 19:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-09  9:34 [PATCH 0/2] Fix built-in rebase perf regression Johannes Schindelin via GitGitGadget
2018-11-09  9:34 ` [PATCH 1/2] rebase: consolidate clean-up code before leaving reset_head() Johannes Schindelin via GitGitGadget
2018-11-09 10:03   ` Jeff King
2018-11-09 17:13     ` Johannes Schindelin
2018-11-09  9:34 ` [PATCH 2/2] built-in rebase: reinstate `checkout -q` behavior where appropriate Johannes Schindelin via GitGitGadget
2018-11-09 10:11   ` Jeff King
2018-11-09 17:21     ` Johannes Schindelin
2018-11-09 19:59       ` Jeff King [this message]
2018-11-12 11:11         ` Johannes Schindelin
2018-11-12  4:04       ` Junio C Hamano
2018-11-12 11:42         ` Johannes Schindelin
2018-11-13  1:49           ` Junio C Hamano
2018-11-13  6:07             ` Junio C Hamano
2018-11-12 11:44 ` [PATCH v2 0/3] Fix built-in rebase perf regression Johannes Schindelin via GitGitGadget
2018-11-12 11:44   ` [PATCH v2 1/3] rebase: consolidate clean-up code before leaving reset_head() Johannes Schindelin via GitGitGadget
2018-11-12 11:44   ` [PATCH v2 2/3] rebase: prepare reset_head() for more flags Johannes Schindelin via GitGitGadget
2018-11-12 11:44   ` [PATCH v2 3/3] built-in rebase: reinstate `checkout -q` behavior where appropriate Johannes Schindelin via GitGitGadget
2018-11-12 14:26   ` [PATCH v2 0/3] Fix built-in rebase perf regression Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181109195934.GC4938@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).