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,DKIM_SIGNED, DKIM_VALID,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 4B8531F5AF for ; Mon, 29 Mar 2021 20:39:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229689AbhC2UjA (ORCPT ); Mon, 29 Mar 2021 16:39:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230381AbhC2Uig (ORCPT ); Mon, 29 Mar 2021 16:38:36 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EAC8C061574 for ; Mon, 29 Mar 2021 13:38:36 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id d10so12351896ils.5 for ; Mon, 29 Mar 2021 13:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=LvxVMwjdWmT/ZmBvU29lMauvDaWa+ym6jD2TsTazmmM=; b=qGe0MgFvV2lbhyN1lwCSFfUJlcpb+Myv2BuXlU3sKtuqnqUnh1tQrW2N//ofulrv7F xwLHvv/hhocyJOWNmXqc0ZQpGWIVPMGSMtQAjeLuZIAsjsn8YN9K/fYTT1jbr1LezdN6 53DTQpVQzqulvQ1VmGsAFpQkvcHMInU9q1nIY12bEmCi1ZosF+mUxutm9P0TWi1t+MAe VEv25jBM69+/QMttASNgYuMkKD7DrdbvMZyuZrhs77jlvdaYYLfGRr9UAeBwMBMsDubt C2It5rz37pTSnOSyoGBKSvX9yj/vZ2MnTlhhqNrJ8SG76sZoNd8yrO4pVhFOb8wVx1ot SQQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LvxVMwjdWmT/ZmBvU29lMauvDaWa+ym6jD2TsTazmmM=; b=mlUmm85VgyqEbVhrovM6uk545EAfylDUmom92L5nEryeCz6+xAAO1oH4l6jtSC1x2h qjWLeoCNClWg8syxhmnu63KvkxzCj978FbPNl0DGfx+qXPPbJRE0ACQmGFOyzbtHD7MR +l9KyNFGAjRbsKW2tjXL0+FHobgBPq6Tu5YTAsPcdQM2LrDGcggK6+nurcMbsO2OX61n gPG76gcyD2HkyjFHq9U1s4fPzsqyvKrbzUvrq20rXZSh54FfcZOTDMiavppDqrTDAF8a 1SCyVoMaZkXKc3rdOxWMlGMR6rLwrNX3A3D9LtJMZdHVT9b9X6M6NLjBq7EXwn3dHUf1 VZUg== X-Gm-Message-State: AOAM533t4iwO3hR5WP8BZkqtUy7MHk281OkK2ZlX7cxz5Juia9pk7TTe /ZENMTPkiC1LbCPgzuJ6vcki4pU5LquiYA== X-Google-Smtp-Source: ABdhPJyZD2YFVsjWZf6yT1jRJ+PfirC5dFntEsrjOeg0iEuWChqU/jJbguO1c8GhedYlijxxx5ID7A== X-Received: by 2002:a05:6e02:92b:: with SMTP id o11mr5381631ilt.279.1617050315893; Mon, 29 Mar 2021 13:38:35 -0700 (PDT) Received: from localhost ([2605:9480:22e:ff10:7b00:4f79:8763:6261]) by smtp.gmail.com with ESMTPSA id z10sm7737695ilq.38.2021.03.29.13.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 13:38:35 -0700 (PDT) Date: Mon, 29 Mar 2021 16:38:33 -0400 From: Taylor Blau To: Jeff King Cc: git@vger.kernel.org, avarab@gmail.com, dstolee@microsoft.com, gitster@pobox.com, jonathantanmy@google.com Subject: Re: [PATCH v3 04/16] builtin/multi-pack-index.c: split sub-commands Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Mar 29, 2021 at 07:36:21AM -0400, Jeff King wrote: > This is definitely a harmless leak in the sense that we are going to > exit the program after midx_repack() returns anyway. But it might be > worth keeping things tidy, as we've recently seen a renewed effort to do > some leak-checking of the test suite. I _think_ we can just free the > options struct (even though we are still using the values themselves, we > don't care about the "struct options" anymore). But even if not, an > UNLEAK(options) annotation would do it. I see what you're saying. Let me make sure that I got the right idea in mind after reading your email. I'm thinking of squashing the following diff into this patch. For what it's worth, it causes 'valgrind --leak-check=full ./git-multi-pack-index repack' to exit cleanly (when it didn't before). Does this match your expectations? --- >8 --- diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c index 23e51dfeb4..a78640c061 100644 --- a/builtin/multi-pack-index.c +++ b/builtin/multi-pack-index.c @@ -56,9 +56,7 @@ static struct option common_opts[] = { static struct option *add_common_options(struct option *prev) { - struct option *with_common = parse_options_concat(common_opts, prev); - free(prev); - return with_common; + return parse_options_concat(common_opts, prev); } static int cmd_multi_pack_index_write(int argc, const char **argv) @@ -112,8 +110,7 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv) OPT_END(), }; - options = parse_options_dup(builtin_multi_pack_index_repack_options); - options = add_common_options(options); + options = add_common_options(builtin_multi_pack_index_repack_options); argc = parse_options(argc, argv, NULL, options, @@ -123,6 +120,8 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv) usage_with_options(builtin_multi_pack_index_repack_usage, options); + FREE_AND_NULL(options); + return midx_repack(the_repository, opts.object_dir, (size_t)opts.batch_size, opts.flags); }