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-ASN: AS53758 23.128.96.0/24 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 E6CD01F953 for ; Mon, 22 Nov 2021 21:10:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238665AbhKVVNX (ORCPT ); Mon, 22 Nov 2021 16:13:23 -0500 Received: from cloud.peff.net ([104.130.231.41]:36700 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbhKVVNW (ORCPT ); Mon, 22 Nov 2021 16:13:22 -0500 Received: (qmail 22310 invoked by uid 109); 22 Nov 2021 21:10:15 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Mon, 22 Nov 2021 21:10:15 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 25558 invoked by uid 111); 22 Nov 2021 21:10:15 -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; Mon, 22 Nov 2021 16:10:15 -0500 Authentication-Results: peff.net; auth=none Date: Mon, 22 Nov 2021 16:10:14 -0500 From: Jeff King To: =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason Cc: git@vger.kernel.org, Junio C Hamano , Enzo Matsumiya Subject: Re: [PATCH 2/5] upload-archive: use regular "struct child_process" pattern Message-ID: References: <211122.86fsrnyko4.gmgdl@evledraar.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <211122.86fsrnyko4.gmgdl@evledraar.gmail.com> Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Nov 22, 2021 at 09:53:34PM +0100, Ævar Arnfjörð Bjarmason wrote: > But as to skipping the "argc > 1" test I've got this still: > > @@ -89,9 +89,11 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix) > * multiplexed out to our fd#1. If the child dies, we tell the other > * end over channel #3. > */ > - argv[0] = "upload-archive--writer"; > writer.out = writer.err = -1; > writer.git_cmd = 1; > + strvec_push(&writer.args, "upload-archive--writer"); > + if (argc > 1) > + strvec_pushv(&writer.args, argv + 1); > if (start_command(&writer)) { > int err = errno; > packet_write_fmt(1, "NACK unable to spawn subprocess\n"); > > We'll segfault if we give NULL to strvec_pushv() so we still need that > check. Were you thinking of strvec_pushl(), or am I missing something? We wouldn't be giving NULL to strvec_pushv(). We'd be giving argv+1, which is guaranteed non-NULL, but may point to NULL. In that case the loop condition in strvec_pushv() would turn it into a noop. -Peff