From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 2B7361F55B for ; Thu, 14 May 2020 17:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726144AbgENR4s (ORCPT ); Thu, 14 May 2020 13:56:48 -0400 Received: from cloud.peff.net ([104.130.231.41]:46612 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1725965AbgENR4s (ORCPT ); Thu, 14 May 2020 13:56:48 -0400 Received: (qmail 16462 invoked by uid 109); 14 May 2020 17:56:48 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Thu, 14 May 2020 17:56:48 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 3019 invoked by uid 111); 14 May 2020 17:56:47 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Thu, 14 May 2020 13:56:47 -0400 Authentication-Results: peff.net; auth=none Date: Thu, 14 May 2020 13:56:46 -0400 From: Jeff King To: Taylor Blau Cc: git@vger.kernel.org, dstolee@microsoft.com, gitster@pobox.com, szeder.dev@gmail.com Subject: Re: [PATCH v3 4/8] builtin/commit-graph.c: extract 'read_one_commit()' Message-ID: <20200514175646.GA2430834@coredump.intra.peff.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Wed, May 13, 2020 at 03:59:41PM -0600, Taylor Blau wrote: > @@ -209,44 +220,35 @@ static int graph_write(int argc, const char **argv) > return 0; > } > > - string_list_init(&lines, 0); > - if (opts.stdin_packs || opts.stdin_commits) { > - struct strbuf buf = STRBUF_INIT; > + struct strbuf buf = STRBUF_INIT; > + if (opts.stdin_packs) { This is a decl-after-statement, isn't it? It should fail with DEVELOPER=1. The strbuf could be local in each block of the conditional, though that makes your cleanup label trickier. Only the stdin_commits side needs to clean up the buf, so we could just do it there. Or I'd be OK with having the strbuf declared at the top of the function, and using the whole-function cleanup label. -Peff