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=-3.4 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,T_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 3994F1F406 for ; Fri, 12 Jan 2018 13:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754495AbeALNFZ (ORCPT ); Fri, 12 Jan 2018 08:05:25 -0500 Received: from cloud.peff.net ([104.130.231.41]:42010 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753875AbeALNFY (ORCPT ); Fri, 12 Jan 2018 08:05:24 -0500 Received: (qmail 3009 invoked by uid 109); 12 Jan 2018 13:05:24 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Fri, 12 Jan 2018 13:05:24 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 30503 invoked by uid 111); 12 Jan 2018 13:05:58 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Fri, 12 Jan 2018 08:05:58 -0500 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Fri, 12 Jan 2018 08:05:22 -0500 Date: Fri, 12 Jan 2018 08:05:22 -0500 From: Jeff King To: =?utf-8?B?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= Duy Cc: git@vger.kernel.org, Stefan Beller , Brandon Williams , Junio C Hamano , Johannes Sixt Subject: Re: [PATCH v3 1/4] trace.c: introduce trace_run_command() Message-ID: <20180112130522.GB27499@sigill.intra.peff.net> References: <20180111094712.2551-1-pclouds@gmail.com> <20180112095607.18293-1-pclouds@gmail.com> <20180112095607.18293-2-pclouds@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180112095607.18293-2-pclouds@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, Jan 12, 2018 at 04:56:04PM +0700, Nguyễn Thái Ngọc Duy wrote: > This is the same as the old code that uses trace_argv_printf() in > run-command.c. This function will be improved in later patches to > print more information from struct child_process. > > A slight regression: the old code would print run-command.c:xxx as the > trace location site while the new code prints trace.c:xxx. This should > be fine until the second call site is added, then we might need a macro > wrapper named trace_run_command() to capture the right source location. I agree that's probably fine for now. > +void trace_run_command(const struct child_process *cp) > +{ > + struct strbuf buf = STRBUF_INIT; > + > + if (!prepare_trace_line(__FILE__, __LINE__, > + &trace_default_key, &buf)) > + return; > + > + strbuf_addf(&buf, "trace: run_command:"); > + > + sq_quote_argv(&buf, cp->argv, 0); > + print_trace_line(&trace_default_key, &buf); > +} It looks like this leaks "buf". If prepare_trace_line() returns 0, I think it's safe to assume that nothing was allocated. So we'd just need a strbuf_release() at the end. Looking at the other trace functions, it looks like a bunch of them have the same problem. -Peff